Exemplo n.º 1
0
 def rebuild(self, req):
     if self.isUsingUserPasswd(req):
         if not self.authUser(req):
             return Redirect("../../../authfailed")
     b = self.build_status
     bc = self.builder_control
     builder_name = b.getBuilder().getName()
     log.msg("web rebuild of build %s:%s" % (builder_name, b.getNumber()))
     name = req.args.get("username", ["<unknown>"])[0]
     comments = req.args.get("comments", ["<no reason specified>"])[0]
     reason = ("The web-page 'rebuild' button was pressed by "
               "'%s': %s\n" % (html.escape(name), html.escape(comments)))
     extraProperties = getAndCheckProperties(req)
     if not bc or not b.isFinished() or extraProperties is None:
         log.msg("could not rebuild: bc=%s, isFinished=%s"
                 % (bc, b.isFinished()))
         # TODO: indicate an error
     else:
         bc.resubmitBuild(b, reason, extraProperties)
     # we're at
     # http://localhost:8080/builders/NAME/builds/5/rebuild?[args]
     # Where should we send them?
     #
     # Ideally it would be to the per-build page that they just started,
     # but we don't know the build number for it yet (besides, it might
     # have to wait for a current build to finish). The next-most
     # preferred place is somewhere that the user can see tangible
     # evidence of their build starting (or to see the reason that it
     # didn't start). This should be the Builder page.
     r = Redirect("../..") # the Builder's page
     d = defer.Deferred()
     reactor.callLater(1, d.callback, r)
     return DeferredResource(d)
Exemplo n.º 2
0
    def performAction(self, req):
        url = None
        authz = self.getAuthz(req)
        res = yield authz.actionAllowed(self.action, req, self.builder)

        if not res:
            url = path_to_authzfail(req)
        else:
            # get a control object
            c = interfaces.IControl(self.getBuildmaster(req))
            bc = c.getBuilder(self.builder.getName())

            b = self.build_status
            builder_name = self.builder.getName()
            log.msg("web rebuild of build %s:%s" % (builder_name, b.getNumber()))
            name = authz.getUsernameFull(req)
            comments = _get_comments_from_request(req)

            reason = self.rebuildString % {
                'build_number': b.getNumber(),
                'owner': b.getInterestedUsers(),
                'rebuild_owner': name,
                'rebuild_comments': comments
            }

            useSourcestamp = req.args.get("useSourcestamp", None)
            if useSourcestamp and useSourcestamp == ['updated']:
                absolute = False
            else:
                absolute = True

            msg = ""
            extraProperties = getAndCheckProperties(req)
            if not bc or not b.isFinished() or extraProperties is None:
                msg = "could not rebuild: "
                if b.isFinished():
                    msg += "build still not finished "
                if bc:
                    msg += "could not get builder control"
            else:
                tup = yield bc.rebuildBuild(b,
                                            reason=reason,
                                            extraProperties=extraProperties,
                                            absolute=absolute)
                # rebuildBuild returns None on error (?!)
                if not tup:
                    msg = "rebuilding a build failed " + str(tup)
            # we're at
            # http://localhost:8080/builders/NAME/builds/5/rebuild?[args]
            # Where should we send them?
            #
            # Ideally it would be to the per-build page that they just started,
            # but we don't know the build number for it yet (besides, it might
            # have to wait for a current build to finish). The next-most
            # preferred place is somewhere that the user can see tangible
            # evidence of their build starting (or to see the reason that it
            # didn't start). This should be the Builder page.

            url = path_to_builder(req, self.builder), msg
        defer.returnValue(url)
Exemplo n.º 3
0
    def force(self, req, auth_ok=False):
        name = req.args.get("username", ["<unknown>"])[0]
        reason = req.args.get("comments", ["<no reason specified>"])[0]
        branch = req.args.get("branch", [""])[0]
        revision = req.args.get("revision", [""])[0]
        repository = req.args.get("repository", [""])[0]
        project = req.args.get("project", [""])[0]

        log.msg("web forcebuild of builder '%s', branch='%s', revision='%s',"
                " repository='%s', project='%s' by user '%s'" %
                (self.builder_status.getName(), branch, revision, repository,
                 project, name))

        # check if this is allowed
        if not auth_ok:
            if not self.getAuthz(req).actionAllowed('forceBuild', req,
                                                    self.builder_status):
                log.msg("..but not authorized")
                return Redirect(path_to_authfail(req))
        # ensure that they've filled out the username field at least.
        if name == "<unknown>":
            log.msg("..but didn't include a username to blame")
            return Redirect(path_to_authfail(req))

        # keep weird stuff out of the branch revision, and property strings.
        # TODO: centralize this somewhere.
        if not re.match(r'^[\w.+/~-]*$', branch):
            log.msg("bad branch '%s'" % branch)
            return Redirect(path_to_builder(req, self.builder_status))
        if not re.match(r'^[ \w\.\-\/]*$', revision):
            log.msg("bad revision '%s'" % revision)
            return Redirect(path_to_builder(req, self.builder_status))
        properties = getAndCheckProperties(req)
        if properties is None:
            return Redirect(path_to_builder(req, self.builder_status))
        if not branch:
            branch = None
        if not revision:
            revision = None

        master = self.getBuildmaster(req)
        d = master.db.sourcestamps.addSourceStamp(branch=branch,
                                                  revision=revision,
                                                  project=project,
                                                  repository=repository)

        def make_buildset(ssid):
            r = (
                "The web-page 'force build' button was pressed by '%s': %s\n" %
                (html.escape(name), html.escape(reason)))
            return master.addBuildset(
                builderNames=[self.builder_status.getName()],
                ssid=ssid,
                reason=r,
                properties=properties.asDict())

        d.addCallback(make_buildset)
        d.addErrback(log.err, "(ignored) while trying to force build")
        # send the user back to the builder page
        return Redirect(path_to_builder(req, self.builder_status))
Exemplo n.º 4
0
    def performAction(self, req):
        url = None
        authz = self.getAuthz(req)
        res = yield authz.actionAllowed(self.action, req, self.builder)

        if not res:
            url = path_to_authzfail(req)
        else:
            # get a control object
            c = interfaces.IControl(self.getBuildmaster(req))
            bc = c.getBuilder(self.builder.getName())

            b = self.build_status
            builder_name = self.builder.getName()
            log.msg("web rebuild of build %s:%s" % (builder_name, b.getNumber()))
            name = authz.getUsernameFull(req)
            comments = _get_comments_from_request(req)

            reason = self.rebuildString % {
                'build_number': b.getNumber(),
                'owner': b.getInterestedUsers(),
                'rebuild_owner': name,
                'rebuild_comments': comments
            }

            useSourcestamp = req.args.get("useSourcestamp", None)
            if useSourcestamp and useSourcestamp == ['updated']:
                absolute = False
            else:
                absolute = True

            msg = ""
            extraProperties = getAndCheckProperties(req)
            if not bc or not b.isFinished() or extraProperties is None:
                msg = "could not rebuild: "
                if not b.isFinished():
                    msg += "build still not finished "
                if not bc:
                    msg += "could not get builder control"
            else:
                tup = yield bc.rebuildBuild(b,
                                            reason=reason,
                                            extraProperties=extraProperties,
                                            absolute=absolute)
                # rebuildBuild returns None on error (?!)
                if not tup:
                    msg = "rebuilding a build failed " + str(tup)
            # we're at
            # http://localhost:8080/builders/NAME/builds/5/rebuild?[args]
            # Where should we send them?
            #
            # Ideally it would be to the per-build page that they just started,
            # but we don't know the build number for it yet (besides, it might
            # have to wait for a current build to finish). The next-most
            # preferred place is somewhere that the user can see tangible
            # evidence of their build starting (or to see the reason that it
            # didn't start). This should be the Builder page.

            url = path_to_builder(req, self.builder), msg
        defer.returnValue(url)
Exemplo n.º 5
0
    def force(self, req, auth_ok=False):
        name = self.getAuthz(req).getUsername(req)
        reason = req.args.get("comments", ["<no reason specified>"])[0]
        branch = req.args.get("branch", [""])[0]
        revision = req.args.get("revision", [""])[0]
        repository = req.args.get("repository", [""])[0]
        project = req.args.get("project", [""])[0]

        log.msg("web forcebuild of builder '%s', branch='%s', revision='%s',"
                " repository='%s', project='%s' by user '%s'" %
                (self.builder_status.getName(), branch, revision, repository,
                 project, name))

        if not auth_ok:
            req_args = dict(name=name,
                            reason=reason,
                            branch=branch,
                            revision=revision,
                            repository=repository,
                            project=project)
            return ForceBuildActionResource(self.builder_status, req_args)

        master = self.getBuildmaster(req)

        # keep weird stuff out of the branch revision, and property strings.
        branch_validate = master.config.validation['branch']
        revision_validate = master.config.validation['revision']
        if not branch_validate.match(branch):
            log.msg("bad branch '%s'" % branch)
            return Redirect(path_to_builder(req, self.builder_status))
        if not revision_validate.match(revision):
            log.msg("bad revision '%s'" % revision)
            return Redirect(path_to_builder(req, self.builder_status))
        properties = getAndCheckProperties(req)
        if properties is None:
            return Redirect(path_to_builder(req, self.builder_status))
        if not branch:
            branch = None
        if not revision:
            revision = None

        d = master.db.sourcestamps.addSourceStamp(branch=branch,
                                                  revision=revision,
                                                  project=project,
                                                  repository=repository)

        def make_buildset(ssid):
            r = (
                "The web-page 'force build' button was pressed by '%s': %s\n" %
                (html.escape(name), html.escape(reason)))
            return master.addBuildset(
                builderNames=[self.builder_status.getName()],
                ssid=ssid,
                reason=r,
                properties=properties.asDict())

        d.addCallback(make_buildset)
        d.addErrback(log.err, "(ignored) while trying to force build")
        # send the user back to the builder page
        return Redirect(path_to_builder(req, self.builder_status))
Exemplo n.º 6
0
    def force(self, req, auth_ok=False):
        name = req.args.get("username", ["<unknown>"])[0]
        reason = req.args.get("comments", ["<no reason specified>"])[0]
        branch = req.args.get("branch", [""])[0]
        revision = req.args.get("revision", [""])[0]
        repository = req.args.get("repository", [""])[0]
        project = req.args.get("project", [""])[0]

        r = "The web-page 'force build' button was pressed by '%s': %s\n" \
            % (html.escape(name), html.escape(reason))
        log.msg("web forcebuild of builder '%s', branch='%s', revision='%s',"
                " repository='%s', project='%s' by user '%s'" %
                (self.builder_status.getName(), branch, revision, repository,
                 project, name))

        # check if this is allowed
        if not auth_ok:
            if not self.getAuthz(req).actionAllowed('forceBuild', req,
                                                    self.builder_status):
                log.msg("..but not authorized")
                return Redirect(path_to_authfail(req))

        # keep weird stuff out of the branch revision, and property strings.
        # TODO: centralize this somewhere.
        if not re.match(r'^[\w.+/~-]*$', branch):
            log.msg("bad branch '%s'" % branch)
            return Redirect(path_to_builder(req, self.builder_status))
        if not re.match(r'^[ \w\.\-\/]*$', revision):
            log.msg("bad revision '%s'" % revision)
            return Redirect(path_to_builder(req, self.builder_status))
        properties = getAndCheckProperties(req)
        if properties is None:
            return Redirect(path_to_builder(req, self.builder_status))
        if not branch:
            branch = None
        if not revision:
            revision = None

        # TODO: if we can authenticate that a particular User pushed the
        # button, use their name instead of None, so they'll be informed of
        # the results.
        # TODO2: we can authenticate that a particular User pushed the button
        # now, so someone can write this support. but it requires a
        # buildbot.changes.changes.Change instance which is tedious at this
        # stage to compute
        s = SourceStamp(branch=branch,
                        revision=revision,
                        project=project,
                        repository=repository)
        try:
            c = interfaces.IControl(self.getBuildmaster(req))
            bc = c.getBuilder(self.builder_status.getName())
            bc.submitBuildRequest(s, r, properties)
        except interfaces.NoSlaveError:
            # TODO: tell the web user that their request could not be
            # honored
            pass
        # send the user back to the builder page
        return Redirect(path_to_builder(req, self.builder_status))
Exemplo n.º 7
0
    def performAction(self, req):
        # check if this is allowed
        d = self.getAuthz(req).actionAllowed(self.action, req,
                                             self.builder_status)
        wfd = defer.waitForDeferred(d)
        yield wfd
        res = wfd.getResult()
        if not res:
            log.msg("..but not authorized")
            yield path_to_authfail(req)
            return

        master = self.getBuildmaster(req)

        # keep weird stuff out of the branch revision, and property strings.
        branch_validate = master.config.validation['branch']
        revision_validate = master.config.validation['revision']
        if not branch_validate.match(self.req_args['branch']):
            log.msg("bad branch '%s'" % self.req_args['branch'])
            yield path_to_builder(req, self.builder_status)
            return
        if not revision_validate.match(self.req_args['revision']):
            log.msg("bad revision '%s'" % self.req_args['revision'])
            yield path_to_builder(req, self.builder_status)
            return
        properties = getAndCheckProperties(req)
        if properties is None:
            yield path_to_builder(req, self.builder_status)
            return
        if not self.req_args['branch']:
            self.req_args['branch'] = None
        if not self.req_args['revision']:
            self.req_args['revision'] = None

        d = master.db.sourcestamps.addSourceStamp(
            branch=self.req_args['branch'],
            revision=self.req_args['revision'],
            project=self.req_args['project'],
            repository=self.req_args['repository'])
        wfd = defer.waitForDeferred(d)
        yield wfd
        ssid = wfd.getResult()

        r = ("The web-page 'force build' button was pressed by '%s': %s\n" %
             (html.escape(
                 self.req_args['name']), html.escape(self.req_args['reason'])))
        d = master.addBuildset(builderNames=[self.builder_status.getName()],
                               ssid=ssid,
                               reason=r,
                               properties=properties.asDict())
        wfd = defer.waitForDeferred(d)
        yield wfd
        tup = wfd.getResult()
        # check that (bsid, brids) were properly stored
        if not isinstance(tup, (int, dict)):
            log.err("(ignored) while trying to force build")

        # send the user back to the builder page
        yield path_to_builder(req, self.builder_status)
Exemplo n.º 8
0
    def performAction(self, req):
        # check if this is allowed
        d = self.getAuthz(req).actionAllowed(self.action, req,
                                             self.builder_status)
        wfd = defer.waitForDeferred(d)
        yield wfd
        res = wfd.getResult()
        if not res:
            log.msg("..but not authorized")
            yield path_to_authfail(req)
            return

        master = self.getBuildmaster(req)

        # keep weird stuff out of the branch revision, and property strings.
        branch_validate = master.config.validation['branch']
        revision_validate = master.config.validation['revision']
        if not branch_validate.match(self.req_args['branch']):
            log.msg("bad branch '%s'" % self.req_args['branch'])
            yield path_to_builder(req, self.builder_status)
            return
        if not revision_validate.match(self.req_args['revision']):
            log.msg("bad revision '%s'" % self.req_args['revision'])
            yield path_to_builder(req, self.builder_status)
            return
        properties = getAndCheckProperties(req)
        if properties is None:
            yield path_to_builder(req, self.builder_status)
            return
        if not self.req_args['branch']:
            self.req_args['branch'] = None
        if not self.req_args['revision']:
            self.req_args['revision'] = None

        d = master.db.sourcestamps.addSourceStamp(
                                      branch=self.req_args['branch'],
                                      revision=self.req_args['revision'],
                                      project=self.req_args['project'],
                                      repository=self.req_args['repository'])
        wfd = defer.waitForDeferred(d)
        yield wfd
        ssid = wfd.getResult()

        r = ("The web-page 'force build' button was pressed by '%s': %s\n"
             % (html.escape(self.req_args['name']),
                html.escape(self.req_args['reason'])))
        d = master.addBuildset(builderNames=[self.builder_status.getName()],
                               ssid=ssid, reason=r,
                               properties=properties.asDict())
        wfd = defer.waitForDeferred(d)
        yield wfd
        tup = wfd.getResult()
        # check that (bsid, brids) were properly stored
        if not isinstance(tup, (int, dict)):
            log.err("(ignored) while trying to force build")

        # send the user back to the builder page
        yield path_to_builder(req, self.builder_status)
Exemplo n.º 9
0
    def force(self, req, auth_ok=False):
        name = req.args.get("username", ["<unknown>"])[0]
        reason = req.args.get("comments", ["<no reason specified>"])[0]
        branch = req.args.get("branch", [""])[0]
        revision = req.args.get("revision", [""])[0]
        repository = req.args.get("repository", [""])[0]
        project = req.args.get("project", [""])[0]

        r = "The web-page 'force build' button was pressed by '%s': %s\n" \
            % (html.escape(name), html.escape(reason))
        log.msg("web forcebuild of builder '%s', branch='%s', revision='%s',"
                " repository='%s', project='%s' by user '%s'" % (
                self.builder_status.getName(), branch, revision, repository,
                project, name))

        # check if this is allowed
        if not auth_ok:
            if not self.getAuthz(req).actionAllowed('forceBuild', req, self.builder_status):
                log.msg("..but not authorized")
                return Redirect(path_to_authfail(req))

        # keep weird stuff out of the branch revision, and property strings.
        # TODO: centralize this somewhere.
        if not re.match(r'^[\w.+/~-]*$', branch):
            log.msg("bad branch '%s'" % branch)
            return Redirect(path_to_builder(req, self.builder_status))
        if not re.match(r'^[ \w\.\-\/]*$', revision):
            log.msg("bad revision '%s'" % revision)
            return Redirect(path_to_builder(req, self.builder_status))
        properties = getAndCheckProperties(req)
        if properties is None:
            return Redirect(path_to_builder(req, self.builder_status))
        if not branch:
            branch = None
        if not revision:
            revision = None

        # TODO: if we can authenticate that a particular User pushed the
        # button, use their name instead of None, so they'll be informed of
        # the results.
        # TODO2: we can authenticate that a particular User pushed the button
        # now, so someone can write this support. but it requires a
        # buildbot.changes.changes.Change instance which is tedious at this
        # stage to compute
        s = SourceStamp(branch=branch, revision=revision, project=project, repository=repository)
        try:
            c = interfaces.IControl(self.getBuildmaster(req))
            bc = c.getBuilder(self.builder_status.getName())
            bc.submitBuildRequest(s, r, properties)
        except interfaces.NoSlaveError:
            # TODO: tell the web user that their request could not be
            # honored
            pass
        # send the user back to the builder page
        return Redirect(path_to_builder(req, self.builder_status))
Exemplo n.º 10
0
    def force(self, req, auth_ok=False):
        name = req.args.get("username", ["<unknown>"])[0]
        reason = req.args.get("comments", ["<no reason specified>"])[0]
        branch = req.args.get("branch", [""])[0]
        revision = req.args.get("revision", [""])[0]
        repository = req.args.get("repository", [""])[0]
        project = req.args.get("project", [""])[0]

        log.msg("web forcebuild of builder '%s', branch='%s', revision='%s',"
                " repository='%s', project='%s' by user '%s'" % (
                self.builder_status.getName(), branch, revision, repository,
                project, name))

        # check if this is allowed
        if not auth_ok:
            if not self.getAuthz(req).actionAllowed('forceBuild', req, self.builder_status):
                log.msg("..but not authorized")
                return Redirect(path_to_authfail(req))
        # ensure that they've filled out the username field at least.
        if name == "<unknown>":
            log.msg("..but didn't include a username to blame")
            return Redirect(path_to_authfail(req))

        master = self.getBuildmaster(req)

        # keep weird stuff out of the branch revision, and property strings.
        branch_validate = master.config.validation['branch']
        revision_validate = master.config.validation['revision']
        if not branch_validate.match(branch):
            log.msg("bad branch '%s'" % branch)
            return Redirect(path_to_builder(req, self.builder_status))
        if not revision_validate.match(revision):
            log.msg("bad revision '%s'" % revision)
            return Redirect(path_to_builder(req, self.builder_status))
        properties = getAndCheckProperties(req)
        if properties is None:
            return Redirect(path_to_builder(req, self.builder_status))
        if not branch:
            branch = None
        if not revision:
            revision = None

        d = master.db.sourcestamps.addSourceStamp(branch=branch,
                revision=revision, project=project, repository=repository)
        def make_buildset(ssid):
            r = ("The web-page 'force build' button was pressed by '%s': %s\n"
                 % (html.escape(name), html.escape(reason)))
            return master.addBuildset(
                    builderNames=[self.builder_status.getName()],
                    ssid=ssid, reason=r, properties=properties.asDict())
        d.addCallback(make_buildset)
        d.addErrback(log.err, "(ignored) while trying to force build")
        # send the user back to the builder page
        return Redirect(path_to_builder(req, self.builder_status))
Exemplo n.º 11
0
    def performAction(self, req):
        url = None
        authz = self.getAuthz(req)
        d = authz.actionAllowed(self.action, req, self.builder)
        wfd = defer.waitForDeferred(d)
        yield wfd
        res = wfd.getResult()

        if not res:
            url = path_to_authzfail(req)
        else:
            # get a control object
            c = interfaces.IControl(self.getBuildmaster(req))
            bc = c.getBuilder(self.builder.getName())

            b = self.build_status
            builder_name = self.builder.getName()
            log.msg("web rebuild of build %s:%s" %
                    (builder_name, b.getNumber()))
            name = authz.getUsernameFull(req)
            comments = req.args.get("comments", ["<no reason specified>"])[0]
            reason = ("The web-page 'rebuild' button was pressed by "
                      "'%s': %s\n" % (name, comments))
            msg = ""
            extraProperties = getAndCheckProperties(req)
            if not bc or not b.isFinished() or extraProperties is None:
                msg = "could not rebuild: "
                if b.isFinished():
                    msg += "build still not finished "
                if bc:
                    msg += "could not get builder control"
            else:
                d = bc.rebuildBuild(b, reason, extraProperties)
                wfd = defer.waitForDeferred(d)
                yield wfd
                tup = wfd.getResult()
                # check that (bsid, brids) were properly stored
                if not (isinstance(tup, tuple) and isinstance(tup[0], int)
                        and isinstance(tup[1], dict)):
                    msg = "rebuilding a build failed " + str(tup)
            # we're at
            # http://localhost:8080/builders/NAME/builds/5/rebuild?[args]
            # Where should we send them?
            #
            # Ideally it would be to the per-build page that they just started,
            # but we don't know the build number for it yet (besides, it might
            # have to wait for a current build to finish). The next-most
            # preferred place is somewhere that the user can see tangible
            # evidence of their build starting (or to see the reason that it
            # didn't start). This should be the Builder page.

            url = path_to_builder(req, self.builder), msg
        yield url
Exemplo n.º 12
0
    def performAction(self, req):
        url = None
        authz = self.getAuthz(req)
        d = authz.actionAllowed(self.action, req, self.builder)
        wfd = defer.waitForDeferred(d)
        yield wfd
        res = wfd.getResult()

        if not res:
            url = path_to_authzfail(req)
        else:
            # get a control object
            c = interfaces.IControl(self.getBuildmaster(req))
            bc = c.getBuilder(self.builder.getName())

            b = self.build_status
            builder_name = self.builder.getName()
            log.msg("web rebuild of build %s:%s" % (builder_name, b.getNumber()))
            name =authz.getUsernameFull(req)
            comments = req.args.get("comments", ["<no reason specified>"])[0]
            reason = ("The web-page 'rebuild' button was pressed by "
                      "'%s': %s\n" % (name, comments))
            msg = ""
            extraProperties = getAndCheckProperties(req)
            if not bc or not b.isFinished() or extraProperties is None:
                msg = "could not rebuild: "
                if b.isFinished():
                    msg += "build still not finished "
                if bc:
                    msg += "could not get builder control"
            else:
                d = bc.rebuildBuild(b, reason, extraProperties)
                wfd = defer.waitForDeferred(d)
                yield wfd
                tup = wfd.getResult()
                # check that (bsid, brids) were properly stored
                if not (isinstance(tup, tuple) and 
                        isinstance(tup[0], int) and
                        isinstance(tup[1], dict)):
                    msg = "rebuilding a build failed "+ str(tup)
            # we're at
            # http://localhost:8080/builders/NAME/builds/5/rebuild?[args]
            # Where should we send them?
            #
            # Ideally it would be to the per-build page that they just started,
            # but we don't know the build number for it yet (besides, it might
            # have to wait for a current build to finish). The next-most
            # preferred place is somewhere that the user can see tangible
            # evidence of their build starting (or to see the reason that it
            # didn't start). This should be the Builder page.

            url = path_to_builder(req, self.builder), msg
        yield url
Exemplo n.º 13
0
    def force(self, req, auth_ok=False):
        name = req.args.get("username", ["<unknown>"])[0]
        reason = req.args.get("comments", ["<no reason specified>"])[0]
        branch = req.args.get("branch", [""])[0]
        revision = req.args.get("revision", [""])[0]
        repository = req.args.get("repository", [""])[0]
        project = req.args.get("project", [""])[0]

        log.msg("web forcebuild of builder '%s', branch='%s', revision='%s',"
                " repository='%s', project='%s' by user '%s'" % (
                self.builder_status.getName(), branch, revision, repository,
                project, name))

        # check if this is allowed
        if not auth_ok:
            if not self.getAuthz(req).actionAllowed('forceBuild', req, self.builder_status):
                log.msg("..but not authorized")
                return Redirect(path_to_authfail(req))

        # keep weird stuff out of the branch revision, and property strings.
        # TODO: centralize this somewhere.
        if not re.match(r'^[\w.+/~-]*$', branch):
            log.msg("bad branch '%s'" % branch)
            return Redirect(path_to_builder(req, self.builder_status))
        if not re.match(r'^[ \w\.\-\/]*$', revision):
            log.msg("bad revision '%s'" % revision)
            return Redirect(path_to_builder(req, self.builder_status))
        properties = getAndCheckProperties(req)
        if properties is None:
            return Redirect(path_to_builder(req, self.builder_status))
        if not branch:
            branch = None
        if not revision:
            revision = None

        master = self.getBuildmaster(req)
        d = master.db.sourcestamps.createSourceStamp(branch=branch,
                revision=revision, project=project, repository=repository)
        def make_buildset(ssid):
            r = ("The web-page 'force build' button was pressed by '%s': %s\n"
                 % (html.escape(name), html.escape(reason)))
            return master.addBuildset(
                    builderNames=[self.builder_status.getName()],
                    ssid=ssid, reason=r, properties=None)
        d.addCallback(make_buildset)
        d.addErrback(log.err, "(ignored) while trying to force build")
        # send the user back to the builder page
        return Redirect(path_to_builder(req, self.builder_status))
Exemplo n.º 14
0
    def rebuild(self, req):
        # check auth
        if not self.getAuthz(req).actionAllowed(
                'forceBuild', req, self.build_status.getBuilder()):
            return Redirect(path_to_authfail(req))

        # get a control object
        c = interfaces.IControl(self.getBuildmaster(req))
        bc = c.getBuilder(self.build_status.getBuilder().getName())

        b = self.build_status
        builder_name = b.getBuilder().getName()
        log.msg("web rebuild of build %s:%s" % (builder_name, b.getNumber()))
        name = req.args.get("username", ["<unknown>"])[0]
        comments = req.args.get("comments", ["<no reason specified>"])[0]
        reason = ("The web-page 'rebuild' button was pressed by "
                  "'%s': %s\n" % (name, comments))
        extraProperties = getAndCheckProperties(req)
        if not bc or not b.isFinished() or extraProperties is None:
            log.msg("could not rebuild: bc=%s, isFinished=%s" %
                    (bc, b.isFinished()))
            # TODO: indicate an error
        else:
            d = bc.rebuildBuild(b, reason, extraProperties)
            d.addErrback(log.err, "while rebuilding a build")
        # we're at
        # http://localhost:8080/builders/NAME/builds/5/rebuild?[args]
        # Where should we send them?
        #
        # Ideally it would be to the per-build page that they just started,
        # but we don't know the build number for it yet (besides, it might
        # have to wait for a current build to finish). The next-most
        # preferred place is somewhere that the user can see tangible
        # evidence of their build starting (or to see the reason that it
        # didn't start). This should be the Builder page.

        r = Redirect(path_to_builder(req, self.build_status.getBuilder()))
        d = defer.Deferred()
        reactor.callLater(1, d.callback, r)
        return DeferredResource(d)
Exemplo n.º 15
0
    def rebuild(self, req):
        # check auth
        if not self.getAuthz(req).actionAllowed('forceBuild', req, self.build_status.getBuilder()):
            return Redirect(path_to_authfail(req))

        # get a control object
        c = interfaces.IControl(self.getBuildmaster(req))
        bc = c.getBuilder(self.build_status.getBuilder().getName())

        b = self.build_status
        builder_name = b.getBuilder().getName()
        log.msg("web rebuild of build %s:%s" % (builder_name, b.getNumber()))
        name = req.args.get("username", ["<unknown>"])[0]
        comments = req.args.get("comments", ["<no reason specified>"])[0]
        reason = ("The web-page 'rebuild' button was pressed by "
                  "'%s': %s\n" % (name, comments))
        extraProperties = getAndCheckProperties(req)
        if not bc or not b.isFinished() or extraProperties is None:
            log.msg("could not rebuild: bc=%s, isFinished=%s"
                    % (bc, b.isFinished()))
            # TODO: indicate an error
        else:
            d = bc.rebuildBuild(b, reason, extraProperties)
            d.addErrback(log.err, "while rebuilding a build")
        # we're at
        # http://localhost:8080/builders/NAME/builds/5/rebuild?[args]
        # Where should we send them?
        #
        # Ideally it would be to the per-build page that they just started,
        # but we don't know the build number for it yet (besides, it might
        # have to wait for a current build to finish). The next-most
        # preferred place is somewhere that the user can see tangible
        # evidence of their build starting (or to see the reason that it
        # didn't start). This should be the Builder page.

        r = Redirect(path_to_builder(req, self.build_status.getBuilder()))
        d = defer.Deferred()
        reactor.callLater(1, d.callback, r)
        return DeferredResource(d)
Exemplo n.º 16
0
    def force(self, req):
        """

        Custom properties can be passed from the web form.  To do
        this, subclass this class, overriding the force() method.  You
        can then determine the properties (usually from form values,
        by inspecting req.args), then pass them to this superclass
        force method.
        
        """
        name = req.args.get("username", ["<unknown>"])[0]
        reason = req.args.get("comments", ["<no reason specified>"])[0]
        branch = req.args.get("branch", [""])[0]
        revision = req.args.get("revision", [""])[0]

        r = "The web-page 'force build' button was pressed by '%s': %s\n" \
            % (html.escape(name), html.escape(reason))
        log.msg("web forcebuild of builder '%s', branch='%s', revision='%s'"
                " by user '%s'" %
                (self.builder_status.getName(), branch, revision, name))

        if not self.builder_control:
            # TODO: tell the web user that their request was denied
            log.msg("but builder control is disabled")
            return Redirect("..")

        if self.isUsingUserPasswd(req):
            if not self.authUser(req):
                return Redirect("../../authfail")

        # keep weird stuff out of the branch revision, and property strings.
        # TODO: centralize this somewhere.
        if not re.match(r'^[\w\.\-\/]*$', branch):
            log.msg("bad branch '%s'" % branch)
            return Redirect("..")
        if not re.match(r'^[\w\.\-\/]*$', revision):
            log.msg("bad revision '%s'" % revision)
            return Redirect("..")
        properties = getAndCheckProperties(req)
        if properties is None:
            return Redirect("..")
        if not branch:
            branch = None
        if not revision:
            revision = None

        # TODO: if we can authenticate that a particular User pushed the
        # button, use their name instead of None, so they'll be informed of
        # the results.
        # TODO2: we can authenticate that a particular User pushed the button
        # now, so someone can write this support. but it requires a
        # buildbot.changes.changes.Change instance which is tedious at this
        # stage to compute
        s = SourceStamp(branch=branch, revision=revision)
        req = BuildRequest(r,
                           s,
                           builderName=self.builder_status.getName(),
                           properties=properties)
        try:
            self.builder_control.requestBuildSoon(req)
        except interfaces.NoSlaveError:
            # TODO: tell the web user that their request could not be
            # honored
            pass
        # send the user back to the builder page
        return Redirect(".")
Exemplo n.º 17
0
    def force(self, req):
        """

        Custom properties can be passed from the web form.  To do
        this, subclass this class, overriding the force() method.  You
        can then determine the properties (usually from form values,
        by inspecting req.args), then pass them to this superclass
        force method.
        
        """
        name = req.args.get("username", ["<unknown>"])[0]
        reason = req.args.get("comments", ["<no reason specified>"])[0]
        branch = req.args.get("branch", [""])[0]
        revision = req.args.get("revision", [""])[0]

        r = "The web-page 'force build' button was pressed by '%s': %s\n" \
            % (html.escape(name), html.escape(reason))
        log.msg("web forcebuild of builder '%s', branch='%s', revision='%s'"
                " by user '%s'" % (self.builder_status.getName(), branch,
                                   revision, name))

        if not self.builder_control:
            # TODO: tell the web user that their request was denied
            log.msg("but builder control is disabled")
            return Redirect("..")

        if self.isUsingUserPasswd(req):
            if not self.authUser(req):
                return Redirect("../../authfail")

        # keep weird stuff out of the branch revision, and property strings.
        # TODO: centralize this somewhere.
        if not re.match(r'^[\w\.\-\/]*$', branch):
            log.msg("bad branch '%s'" % branch)
            return Redirect("..")
        if not re.match(r'^[\w\.\-\/]*$', revision):
            log.msg("bad revision '%s'" % revision)
            return Redirect("..")
        properties = getAndCheckProperties(req)
        if properties is None:
            return Redirect("..")
        if not branch:
            branch = None
        if not revision:
            revision = None

        # TODO: if we can authenticate that a particular User pushed the
        # button, use their name instead of None, so they'll be informed of
        # the results.
        # TODO2: we can authenticate that a particular User pushed the button
        # now, so someone can write this support. but it requires a
        # buildbot.changes.changes.Change instance which is tedious at this
        # stage to compute
        s = SourceStamp(branch=branch, revision=revision)
        req = BuildRequest(r, s, builderName=self.builder_status.getName(),
                           properties=properties)
        try:
            self.builder_control.requestBuildSoon(req)
        except interfaces.NoSlaveError:
            # TODO: tell the web user that their request could not be
            # honored
            pass
        # send the user back to the builder page
        return Redirect(".")