Skip to content

Commit 2eb0969

Browse files
committed
Set Build status to Done when return code is 403
resolves: adoptium#1060 Signed-off-by: Lan Xia <Lan_Xia@ca.ibm.com>
1 parent ea5e23d commit 2eb0969

File tree

2 files changed

+13
-7
lines changed

2 files changed

+13
-7
lines changed

TestResultSummaryService/BuildProcessor.js

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -22,12 +22,15 @@ class BuildProcessor {
2222
);
2323

2424
if (buildInfo) {
25-
if (buildInfo.code === 404) {
25+
if (buildInfo.code === 404 || buildInfo.code === 403) {
2626
/*
27-
* Return code is 404. The url is invalid or the build does not
28-
* exist on Jenkins any more, just set status to Done and store
29-
* the build info
27+
* The url is invalid or the build does not exist on Jenkins any more
28+
* (return code is 404 or 403), just set status to Done and store the
29+
* build info.
3030
*/
31+
logger.warn(
32+
`buildInfo.code: ${buildInfo.code}. Set build ${url} status to Done.`
33+
);
3134
task.status = 'Done';
3235
await new DataManager().updateBuild(task);
3336
await new AuditLogsDB().insertAuditLogs({

TestResultSummaryService/JenkinsInfo.js

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -27,10 +27,13 @@ const retry = (fn) => {
2727
logger.warn(`status code: ${e.statusCode}`);
2828
logger.warn(`headers: ${JSON.stringify(e.headers)}`);
2929

30-
// return code 404 only if the Jenkins server returns 404 for the build (i.e., invalid url, expired build, etc)
30+
// return code 404 or 403 from the Jenkins server (i.e., invalid url, expired build, etc)
3131
// x-jenkins header is checked to ensure the error code is from Jenkins (not nginx)
32-
// TRSS will stop processing this build once code 404 is returned. See BuildProcessor for details.
33-
if (e.statusCode === 404 && e.headers['x-jenkins']) {
32+
// TRSS will stop processing this build once code 404 or 403 is returned. See BuildProcessor for details.
33+
if (
34+
(e.statusCode === 404 || e.statusCode === 403) &&
35+
e.headers['x-jenkins']
36+
) {
3437
return { code: e.statusCode };
3538
}
3639
}

0 commit comments

Comments
 (0)