From ea15090bb396ac46df6d41766869f516d0d2708c Mon Sep 17 00:00:00 2001 From: Tim Jacomb Date: Mon, 3 Aug 2020 09:29:10 +0100 Subject: [PATCH] Add support for restarting builds --- plugins/jenkins/src/api/index.ts | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/plugins/jenkins/src/api/index.ts b/plugins/jenkins/src/api/index.ts index fba45e3b88..0218a14cac 100644 --- a/plugins/jenkins/src/api/index.ts +++ b/plugins/jenkins/src/api/index.ts @@ -34,8 +34,8 @@ export class JenkinsApi { } async retry(buildName: string) { - // looks like current SDK may not support this or at least not very well - // can't see any support for replay + // looks like the current SDK only supports triggering a new build + // can't see any support for replay (re-running the specific build with the same SCM info) return await this.jenkins.job.build(buildName); } @@ -89,11 +89,17 @@ export class JenkinsApi { }) .pop(); + const path = new URL(jenkinsResult.url).pathname; + return { - id: new URL(jenkinsResult.url).pathname, + id: path, buildName: jenkinsResult.fullDisplayName, status: jenkinsResult.building ? 'running' : jenkinsResult.result, - onRestartClick: () => {}, + onRestartClick: () => { + // TODO: this won't handle non root context path, need a better way to get the job name + const { jobName } = this.extractJobDetailsFromBuildName(path); + return this.retry(jobName); + }, source: source, }; }