def rebuild_build(self, branch): """Rebuild `build_id`, which must be passed in as a POST parameter. `priority` is also accepted as an optional parameter.""" who = self._require_auth() if branch not in self._branches_cache: return self._failed("Branch %s not found" % branch, 404) try: build_id = IntValidator.to_python(request.POST.get('build_id')) except formencode.Invalid: return self._failed('Bad build_id', 400) try: priority = validators.Int(if_empty=0).to_python(request.POST.get('priority')) except formencode.Invalid: return self._failed('Bad priority', 400) retval = getBuild(branch, build_id) if not retval: return self._failed("Build %s not found on branch %s" % (build_id, branch), 404) access_log.info("%s rebuild_build %s %s %s", who, branch, build_id, priority) retval = g.mq.rebuildBuild(who, build_id, priority) # TODO: invalidate cache for branch return self._format_mq_response(retval)
def rebuild_build(self, branch): """Rebuild `build_id`, which must be passed in as a POST parameter. `priority` and `count` are also accepted as optional parameters. `count` defaults to 1, and represents the number of times this build will be rebuilt.""" who = self._require_auth() if branch not in self._branches_cache: return self._failed("Branch %s not found" % branch, 404) try: build_id = IntValidator.to_python(request.POST.get('build_id')) except formencode.Invalid: return self._failed('Bad build_id', 400) try: priority = validators.Int(if_empty=0).to_python(request.POST.get('priority')) except formencode.Invalid: return self._failed('Bad priority', 400) try: count = validators.Int(if_empty=1).to_python(request.POST.get('count')) except formencode.Invalid: return self._failed('Bad count', 400) retval = getBuild(branch, build_id) if not retval: return self._failed("Build %s not found on branch %s" % (build_id, branch), 404) access_log.info("%s rebuild_build %s %s %s %s", who, branch, build_id, priority, count) retval = g.mq.rebuildBuild(who, build_id, priority, count) # TODO: invalidate cache for branch return self._format_mq_response(retval)
def build(self, branch, build_id): """Return information about a build""" if branch not in self._branches_cache: return self._failed("Branch %s not found" % branch, 404) retval = getBuild(branch, build_id) if not retval: return self._failed("Build %s not found on branch %s" % (build_id, branch), 404) return self._ok(retval)
def cancel_build(self, branch, build_id): """Cancel the given build""" who = self._require_auth() if branch not in self._branches_cache: return self._failed("Branch %s not found" % branch, 404) try: build_id = int(build_id) except ValueError: return self._failed('Non-integer build_id', 400) retval = getBuild(branch, build_id) if not retval: return self._failed("Build %s not found on branch %s" % (build_id, branch), 404) access_log.info("%s cancel_build %s %s", who, branch, build_id) retval = g.mq.cancelBuild(who, build_id) # TODO: invalidate cache for branch return self._format_mq_response(retval)