зеркало из https://github.com/mozilla/treeherder.git
Bug 1121998 - Add the ability to retrigger all pinned jobs
This commit is contained in:
Родитель
ba82ca5895
Коммит
e3b276268c
|
@ -133,9 +133,10 @@ def test_job_retrigger_unauthorized(webapp, eleven_jobs_stored, jm):
|
|||
Validate that only authenticated users can hit this endpoint.
|
||||
"""
|
||||
job = jm.get_job_list(0, 1)[0]
|
||||
job_id_list = [job["id"]]
|
||||
url = reverse("jobs-retrigger",
|
||||
kwargs={"project": jm.project, "pk": job["id"]})
|
||||
webapp.post(url, status=403)
|
||||
kwargs={"project": jm.project})
|
||||
webapp.post(url, {"job_id_list": job_id_list}, status=403)
|
||||
|
||||
|
||||
def test_job_retrigger_authorized(webapp, eleven_jobs_stored, jm,
|
||||
|
@ -149,9 +150,10 @@ def test_job_retrigger_authorized(webapp, eleven_jobs_stored, jm,
|
|||
client.force_authenticate(user=user)
|
||||
|
||||
job = jm.get_job_list(0, 1)[0]
|
||||
job_id_list = [job["id"]]
|
||||
url = reverse("jobs-retrigger",
|
||||
kwargs={"project": jm.project, "pk": job["id"]})
|
||||
client.post(url)
|
||||
kwargs={"project": jm.project})
|
||||
client.post(url, {"job_id_list": job_id_list}, format='json')
|
||||
|
||||
message = pulse_action_consumer.get(block=True, timeout=2)
|
||||
content = json.loads(message.body)
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
# file, you can obtain one at http://mozilla.org/MPL/2.0/.
|
||||
from rest_framework import viewsets
|
||||
from rest_framework.response import Response
|
||||
from rest_framework.decorators import detail_route
|
||||
from rest_framework.decorators import detail_route, list_route
|
||||
from rest_framework.reverse import reverse
|
||||
from rest_framework.permissions import IsAuthenticated
|
||||
|
||||
|
@ -134,19 +134,21 @@ class JobsViewSet(viewsets.ViewSet):
|
|||
else:
|
||||
return Response("No job with id: {0}".format(pk), 404)
|
||||
|
||||
@detail_route(methods=['post'], permission_classes=[IsAuthenticated])
|
||||
@list_route(methods=['post'], permission_classes=[IsAuthenticated])
|
||||
@with_jobs
|
||||
def retrigger(self, request, project, jm, pk=None):
|
||||
def retrigger(self, request, project, jm):
|
||||
"""
|
||||
Issue a "retrigger" to the underlying build_system_type by scheduling a
|
||||
pulse message.
|
||||
"""
|
||||
job = jm.get_job(pk)
|
||||
if job:
|
||||
jm.retrigger(request.user.email, job[0])
|
||||
return Response({"message": "retriggered job '{0}'".format(job[0]['job_guid'])})
|
||||
else:
|
||||
return Response("No job with id: {0}".format(pk), 404)
|
||||
job_id_list = request.data["job_id_list"]
|
||||
for pk in job_id_list:
|
||||
job = jm.get_job(pk)
|
||||
if job:
|
||||
jm.retrigger(request.user.email, job[0])
|
||||
return Response({"message": "retriggered job '{0}'".format(job[0]['job_guid'])})
|
||||
else:
|
||||
return Response("No job with id: {0}".format(pk), 404)
|
||||
|
||||
@detail_route(methods=['post'], permission_classes=[IsStaffOrReadOnly])
|
||||
@with_jobs
|
||||
|
|
|
@ -83,12 +83,12 @@ treeherder.factory('ThJobModel', [
|
|||
});
|
||||
};
|
||||
|
||||
ThJobModel.retrigger = function(repoName, pk, config) {
|
||||
ThJobModel.retrigger = function(repoName, job_id_list, config) {
|
||||
config = config || {};
|
||||
var timeout = config.timeout || null;
|
||||
|
||||
return $http.post(ThJobModel.get_uri(repoName)+pk+"/retrigger/",
|
||||
{timeout:timeout})
|
||||
return $http.post(ThJobModel.get_uri(repoName)+"retrigger/",
|
||||
{job_id_list:job_id_list, timeout:timeout})
|
||||
.then(function(response) {
|
||||
return new ThJobModel(response.data);
|
||||
});
|
||||
|
|
|
@ -81,6 +81,7 @@
|
|||
<ul class="dropdown-menu pull-right" role="menu">
|
||||
<li><a ng-click="saveClassificationOnly()">Save classification only</a></li>
|
||||
<li><a ng-click="saveBugsOnly()">Save bugs only</a></li>
|
||||
<li><a ng-click="retriggerAllPinnedJobs()">Retrigger All</a></li>
|
||||
<li><a ng-click="unPinAll()">Clear all</a></li>
|
||||
</ul>
|
||||
</div>
|
||||
|
|
|
@ -278,37 +278,34 @@ treeherder.controller('PluginCtrl', [
|
|||
}
|
||||
};
|
||||
|
||||
$scope.retriggerJob = function() {
|
||||
$scope.retriggerJob = function(jobs) {
|
||||
if ($scope.user.loggedin) {
|
||||
// Only enter a retrigger if we have a valid loaded job, if the user
|
||||
// tries to retrigger eg. via shortcut before the load we warn them
|
||||
if ($scope.job.id) {
|
||||
// The logic here is somewhat complicated because we need to support
|
||||
// two use cases the first is the case where we notify a system
|
||||
// other then buildbot that a retrigger has been requested. The
|
||||
// second is when we have the buildapi id and need to send a request
|
||||
// to the self serve api (which does not listen over pulse!).
|
||||
ThJobModel.retrigger($scope.repoName, $scope.job.id).then(function() {
|
||||
// XXX: Bug 1170839 disables buildapi retrigger requests for the ash branch
|
||||
if($scope.repoName === "ash") {
|
||||
return;
|
||||
}
|
||||
// XXX: Remove this after 1134929 is resolved.
|
||||
var requestId = getBuildbotRequestId();
|
||||
if (requestId) {
|
||||
return thBuildApi.retriggerJob($scope.repoName, requestId);
|
||||
}
|
||||
}).then(function() {
|
||||
thNotify.send("Retriggered job: " + $scope.jobSearchStr,
|
||||
'success');
|
||||
}).catch(function(e) {
|
||||
// Generic error eg. the user doesn't have LDAP access
|
||||
thNotify.send(
|
||||
ThModelErrors.format(e, "Unable to send retrigger"), 'danger');
|
||||
});
|
||||
} else {
|
||||
thNotify.send("Job not yet loaded for retrigger", 'warning');
|
||||
}
|
||||
var job_id_list = _.pluck(jobs, 'id');
|
||||
// The logic here is somewhat complicated because we need to support
|
||||
// two use cases the first is the case where we notify a system
|
||||
// other then buildbot that a retrigger has been requested. The
|
||||
// second is when we have the buildapi id and need to send a request
|
||||
// to the self serve api (which does not listen over pulse!).
|
||||
ThJobModel.retrigger($scope.repoName, job_id_list).then(function() {
|
||||
// XXX: Bug 1170839 disables buildapi retrigger requests for the ash branch
|
||||
if($scope.repoName === "ash") {
|
||||
return;
|
||||
}
|
||||
// XXX: Remove this after 1134929 is resolved.
|
||||
return ThJobArtifactModel.get_list({"name": "buildapi", "type": "json", "job_id__in": job_id_list.join(',')})
|
||||
.then(function(data) {
|
||||
var request_id_list = _.pluck(_.pluck(data, 'blob'), 'request_id');
|
||||
_.each(request_id_list, function(request_id) {
|
||||
thBuildApi.retriggerJob($scope.repoName, request_id);
|
||||
});
|
||||
});
|
||||
}).then(function() {
|
||||
thNotify.send("Retrigger request sent", "success");
|
||||
}, function(e) {
|
||||
// Generic error eg. the user doesn't have LDAP access
|
||||
thNotify.send(
|
||||
ThModelErrors.format(e, "Unable to send retrigger"), 'danger');
|
||||
});
|
||||
} else {
|
||||
thNotify.send("Must be logged in to retrigger a job", 'danger');
|
||||
}
|
||||
|
@ -424,7 +421,7 @@ treeherder.controller('PluginCtrl', [
|
|||
});
|
||||
|
||||
$rootScope.$on(thEvents.jobRetrigger, function(event, job) {
|
||||
$scope.retriggerJob();
|
||||
$scope.retriggerJob([job]);
|
||||
});
|
||||
|
||||
$rootScope.$on(thEvents.jobsClassified, function(event, job) {
|
||||
|
|
|
@ -101,6 +101,11 @@ treeherder.controller('PinboardCtrl', [
|
|||
}
|
||||
};
|
||||
|
||||
$scope.retriggerAllPinnedJobs = function() {
|
||||
// pushing pinned jobs to a list.
|
||||
$scope.retriggerJob(_.values($scope.pinnedJobs));
|
||||
};
|
||||
|
||||
$scope.hasPinnedJobs = function() {
|
||||
return thPinboard.hasPinnedJobs();
|
||||
};
|
||||
|
|
|
@ -97,7 +97,7 @@
|
|||
class="icon-green"
|
||||
href="" prevent-default-on-left-click
|
||||
target="_blank"
|
||||
ng-click="retriggerJob()">
|
||||
ng-click="retriggerJob([selectedJob])">
|
||||
<span class="fa fa-repeat"></span>
|
||||
</a>
|
||||
</li>
|
||||
|
|
Загрузка…
Ссылка в новой задаче