[Buildbot-commits] buildbot/buildbot/status html.py,1.75,1.76 builder.py,1.70,1.71

Brian Warner warner at users.sourceforge.net
Sat Nov 5 21:06:17 UTC 2005


Update of /cvsroot/buildbot/buildbot/buildbot/status
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv17285/buildbot/status

Modified Files:
	html.py builder.py 
Log Message:
Revision: arch at buildbot.sf.net--2004/buildbot--dev--0--patch-408
Creator:  Brian Warner <warner at monolith.lothar.com>

add resubmit-build, change Step URLs

	* buildbot/interfaces.py (IBuilderControl.resubmitBuild): new
	method, takes an IBuildStatus and rebuilds it. It might make more
	sense to add this to IBuildControl instead, but that instance goes
	away completely once the build has finished, and resubmitting
	builds can take place weeks later.
	* buildbot/process/builder.py (BuilderControl.resubmitBuild): same
	* buildbot/status/html.py (StatusResourceBuild): also stash an
	IBuilderControl so we can use resubmitBuild.
	(StatusResourceBuild.body): render "resubmit" button if we can.
	Also add hrefs for each BuildStep
	(StatusResourceBuild.rebuild): add action for "resubmit" button
	(StatusResourceBuilder.getChild): give it an IBuilderControl

	* buildbot/status/builder.py (Status.getURLForThing): change the
	URL for BuildSteps to have a "step-" prefix, so the magic URLs
	that live as targets of buttons like "stop" and "rebuild" can't
	collide with them.
	* buildbot/status/builder.py (Status.getURLForThing): same
	* buildbot/status/html.py (StatusResourceBuild.getChild): same
	(StepBox.getBox): same
	* buildbot/test/test_web.py (GetURL): same
	(Logfile): same

	* buildbot/process/step.py (SVN.__init__): put svnurl/baseURL
	exclusivity checks after Source.__init__ upcall, so misspelled
	arguments will be reported more usefully
	(Darcs.__init__): same


Index: builder.py
===================================================================
RCS file: /cvsroot/buildbot/buildbot/buildbot/status/builder.py,v
retrieving revision 1.70
retrieving revision 1.71
diff -u -d -r1.70 -r1.71
--- builder.py	23 Oct 2005 05:06:02 -0000	1.70
+++ builder.py	5 Nov 2005 21:06:15 -0000	1.71
@@ -1764,7 +1764,7 @@
             return "%s%s/builds/%d/%s" % (prefix,
                                           builder.getName(),
                                           build.getNumber(),
-                                          step.getName())
+                                          "step-" + step.getName())
         # IBuildSetStatus
         # IBuildRequestStatus
         # ISlaveStatus
@@ -1793,7 +1793,7 @@
             return "%s%s/builds/%d/%s/%d" % (prefix,
                                              builder.getName(),
                                              build.getNumber(),
-                                             step.getName(),
+                                             "step-" + step.getName(),
                                              lognum)
 
 

Index: html.py
===================================================================
RCS file: /cvsroot/buildbot/buildbot/buildbot/status/html.py,v
retrieving revision 1.75
retrieving revision 1.76
diff -u -d -r1.75 -r1.76
--- html.py	26 Oct 2005 21:33:20 -0000	1.75
+++ html.py	5 Nov 2005 21:06:15 -0000	1.76
@@ -305,11 +305,12 @@
 class StatusResourceBuild(HtmlResource):
     title = "Build"
 
-    def __init__(self, status, build, control):
+    def __init__(self, status, build, builderControl, buildControl):
         HtmlResource.__init__(self)
         self.status = status
         self.build = build
-        self.control = control
+        self.builderControl = builderControl
+        self.control = buildControl
 
     def body(self, request):
         b = self.build
@@ -335,7 +336,6 @@
             and not b.getChanges()):
             data += "  <li>build of most recent revision</li>\n"
         data += " </ul>\n"
-
         if b.isFinished():
             data += "<h4>Buildslave: %s</h4>\n" % html.escape(b.getSlavename())
             data += "<h2>Results:</h2>\n"
@@ -359,12 +359,38 @@
                 </form>
                 """
 
+        if b.isFinished() and self.builderControl is not None:
+            data += "<h3>Resubmit Build:</h3>\n"
+            # can we rebuild it exactly?
+            exactly = (revision is not None) or b.getChanges()
+            if exactly:
+                data += ("<p>This tree was built from a specific set of \n"
+                         "source files, and can be rebuilt exactly</p>\n")
+            else:
+                data += ("<p>This tree was built from the most recent "
+                         "revision")
+                if branch:
+                    data += " (along some branch)"
+                data += (" and thus it might not be possible to rebuild it \n"
+                         "exactly. Any changes that have been committed \n"
+                         "after this build was started <b>will</b> be \n"
+                         "included in a rebuild.</p>\n")
+            rebuildURL = urllib.quote(request.childLink("rebuild"))
+            data += ('<form action="%s" class="command rebuild">\n'
+                     % rebuildURL)
+            data += make_row("Your name:",
+                             "<input type='text' name='username' />")
+            data += make_row("Reason for re-running build:",
+                             "<input type='text' name='comments' />")
+            data += '<input type="submit" value="Rebuild" />\n'
+
         data += "<h2>Steps and Logfiles:</h2>\n"
         if b.getLogs():
             data += "<ol>\n"
             for s in b.getSteps():
-                data += " <li>%s [%s]\n" % (s.getName(),
-                                            " ".join(s.getText()))
+                data += (" <li><a href=\"%s\">%s</a> [%s]\n"
+                         % (self.status.getURLForThing(s), s.getName(),
+                            " ".join(s.getText())))
                 if s.getLogs():
                     data += "  <ol>\n"
                     for logfile in s.getLogs():
@@ -409,19 +435,43 @@
         reactor.callLater(1, d.callback, r)
         return DeferredResource(d)
 
+    def rebuild(self, request):
+        log.msg("web rebuild of build %s:%s" % \
+                (self.build.getBuilder().getName(),
+                 self.build.getNumber()))
+        name = request.args.get("username", ["<unknown>"])[0]
+        comments = request.args.get("comments", ["<no reason specified>"])[0]
+        reason = ("The web-page 'rebuild' button was pressed by "
+                  "'%s': %s\n" % (name, comments))
+        if not self.builderControl or not self.build.isFinished():
+            log.msg("could not rebuild: bc=%s, isFinished=%s"
+                    % (self.builderControl, self.build.isFinished()))
+            # TODO: indicate an error
+        else:
+            self.builderControl.resubmitBuild(self.build, reason)
+        # we're at http://localhost:8080/svn-hello/builds/5/rebuild?[args] and
+        # we want to go to the top, at http://localhost:8080/
+        r = Redirect("../../..")
+        d = defer.Deferred()
+        reactor.callLater(1, d.callback, r)
+        return DeferredResource(d)
+
     def getChild(self, path, request):
         if path == "tests":
-            # TODO: this will collide with a step named 'tests'
             return StatusResourceTestResults(self.status,
                                              self.build.getTestResults())
         if path == "stop":
             return self.stop(request)
-        stepname = path
-        steps = self.build.getSteps()
-        for s in steps:
-            if s.getName() == stepname:
-                return StatusResourceBuildStep(self.status, s)
-        return NoResource("No such BuildStep '%s'" % stepname)
+        if path == "rebuild":
+            return self.rebuild(request)
+        if path.startswith("step-"):
+            stepname = path[len("step-"):]
+            steps = self.build.getSteps()
+            for s in steps:
+                if s.getName() == stepname:
+                    return StatusResourceBuildStep(self.status, s)
+            return NoResource("No such BuildStep '%s'" % stepname)
+        return NoResource("No such resource '%s'" % path)
 
 # $builder
 class StatusResourceBuilder(HtmlResource):
@@ -575,7 +625,8 @@
                 control = None
                 if self.control:
                     control = self.control.getBuild(num)
-                return StatusResourceBuild(self.status, build, control)
+                return StatusResourceBuild(self.status, build,
+                                           self.control, control)
             else:
                 return NoResource("No such build '%d'" % num)
         return NoResource("really weird URL %s" % path)
@@ -876,9 +927,9 @@
 
     def getBox(self):
         b = self.original.getBuild()
-        urlbase = "%s/builds/%d/%s" % (b.getBuilder().getName(),
-                                       b.getNumber(),
-                                       self.original.getName())
+        urlbase = "%s/builds/%d/step-%s" % (b.getBuilder().getName(),
+                                            b.getNumber(),
+                                            self.original.getName())
         text = self.original.getText()
         if text is None:
             log.msg("getText() gave None", urlbase)





More information about the Commits mailing list