зеркало из https://github.com/mozilla/treeherder.git
fix retrigger/cancel to use request id
This commit is contained in:
Родитель
21c8d34664
Коммит
10b193765d
|
@ -8,22 +8,22 @@ treeherder.factory('thBuildApi', [
|
||||||
var selfServeUrl = "https://secure.pub.build.mozilla.org/buildapi/self-serve/";
|
var selfServeUrl = "https://secure.pub.build.mozilla.org/buildapi/self-serve/";
|
||||||
|
|
||||||
return {
|
return {
|
||||||
retriggerJob: function(repoName, buildId) {
|
retriggerJob: function(repoName, requestId) {
|
||||||
|
|
||||||
$http({
|
$http({
|
||||||
url: selfServeUrl + repoName + "/build",
|
url: selfServeUrl + repoName + "/request",
|
||||||
method: "POST",
|
method: "POST",
|
||||||
data: "build_id=" + buildId,
|
data: "request_id=" + requestId,
|
||||||
headers: {
|
headers: {
|
||||||
"Content-Type": "application/x-www-form-urlencoded"
|
"Content-Type": "application/x-www-form-urlencoded"
|
||||||
},
|
},
|
||||||
withCredentials: true
|
withCredentials: true
|
||||||
}).
|
}).then(
|
||||||
success(function(data) {
|
function(data) {
|
||||||
thNotify.send("job " + buildId + " retriggered");
|
thNotify.send("job with request of " + requestId + " retriggered");
|
||||||
}).
|
},
|
||||||
error(function(data) {
|
function(data) {
|
||||||
thNotify.send("job " + buildId + " retrigger FAILED", "danger");
|
thNotify.send("job with request of " + requestId + " retrigger FAILED", "danger");
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
cancelJob: function(repoName, requestId) {
|
cancelJob: function(repoName, requestId) {
|
||||||
|
@ -35,6 +35,12 @@ treeherder.factory('thBuildApi', [
|
||||||
"Content-Type": "application/x-www-form-urlencoded"
|
"Content-Type": "application/x-www-form-urlencoded"
|
||||||
},
|
},
|
||||||
withCredentials: true
|
withCredentials: true
|
||||||
|
}).
|
||||||
|
success(function(data) {
|
||||||
|
thNotify.send("job with request of " + requestId + " cancelled");
|
||||||
|
}).
|
||||||
|
error(function(data) {
|
||||||
|
thNotify.send("job with request of " + requestId + " cancel FAILED", "danger");
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
cancelAll: function(repoName, revision) {
|
cancelAll: function(repoName, revision) {
|
||||||
|
|
|
@ -107,23 +107,10 @@ treeherder.controller('PluginCtrl', [
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
$scope.canRetrigger = function() {
|
|
||||||
if ($scope.job && $scope.artifacts) {
|
|
||||||
if ($scope.job.state === "pending" && $scope.artifacts.buildapi_pending) {
|
|
||||||
return true;
|
|
||||||
} else if (($scope.job.state === "running" ||
|
|
||||||
$scope.job.state === "completed") && $scope.artifacts.buildapi_running) {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return false;
|
|
||||||
};
|
|
||||||
|
|
||||||
$scope.canCancel = function() {
|
$scope.canCancel = function() {
|
||||||
if ($scope.job && $scope.artifacts) {
|
if ($scope.job && $scope.artifacts) {
|
||||||
if ($scope.job.state === "pending" && $scope.artifacts.buildapi_pending) {
|
if (($scope.job.state === "pending" || $scope.job.state === "running") &&
|
||||||
return true;
|
($scope.artifacts.buildapi_pending || $scope.artifacts.buildapi_running)) {
|
||||||
} else if ($scope.job.state === "pending" && $scope.artifacts.buildapi_pending) {
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -134,20 +121,29 @@ treeherder.controller('PluginCtrl', [
|
||||||
* Get the build_id needed to cancel or retrigger from the currently
|
* Get the build_id needed to cancel or retrigger from the currently
|
||||||
* selected job.
|
* selected job.
|
||||||
*/
|
*/
|
||||||
var getBuildId = function() {
|
var getRequestId = function() {
|
||||||
if ($scope.job.state === 'pending') {
|
if ($scope.artifacts.buildapi_pending) {
|
||||||
return $scope.artifacts.buildapi_pending.blob.id;
|
return $scope.artifacts.buildapi_pending.blob.id;
|
||||||
} else if ($scope.job.state === 'running' || $scope.job.state === 'completed') {
|
} else if ($scope.artifacts.buildapi_running &&
|
||||||
return $scope.artifacts.buildapi_running.blob.id;
|
$scope.artifacts.buildapi_running.blob.request_ids.length > 0) {
|
||||||
|
return $scope.artifacts.buildapi_running.blob.request_ids[0];
|
||||||
|
} else if ($scope.artifacts.buildapi_complete &&
|
||||||
|
$scope.artifacts.buildapi_complete.blob.request_ids.length > 0) {
|
||||||
|
return $scope.artifacts.buildapi_complete.blob.request_ids[0];
|
||||||
|
} else {
|
||||||
|
// this is super unlikely since we'd need to have at least one of those
|
||||||
|
// artifacts to even create the job in treeherder. This is just a fallback...
|
||||||
|
thNotify.send("Unable to get request id for retrigger/cancel", "danger", true);
|
||||||
|
return null;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
$scope.retriggerJob = function() {
|
$scope.retriggerJob = function() {
|
||||||
thBuildApi.retriggerJob($scope.repoName, getBuildId());
|
thBuildApi.retriggerJob($scope.repoName, getRequestId());
|
||||||
};
|
};
|
||||||
|
|
||||||
$scope.cancelJob = function() {
|
$scope.cancelJob = function() {
|
||||||
thBuildApi.cancelJob($scope.repoName, getBuildId());
|
thBuildApi.cancelJob($scope.repoName, getRequestId());
|
||||||
};
|
};
|
||||||
|
|
||||||
$scope.cancelAll = function(resultsetId) {
|
$scope.cancelAll = function(resultsetId) {
|
||||||
|
|
|
@ -10,7 +10,7 @@
|
||||||
<span class="fa fa-stop"></span>
|
<span class="fa fa-stop"></span>
|
||||||
</a>
|
</a>
|
||||||
</li>
|
</li>
|
||||||
<li ng-show="canRetrigger()">
|
<li>
|
||||||
<a title="Retrigger job"
|
<a title="Retrigger job"
|
||||||
href=""
|
href=""
|
||||||
target="_blank"
|
target="_blank"
|
||||||
|
|
Загрузка…
Ссылка в новой задаче