diff --git a/pom.xml b/pom.xml index 415cdd9..3afb70b 100644 --- a/pom.xml +++ b/pom.xml @@ -11,7 +11,7 @@ jenkins-releases Jenkins Releases - http://repo.jenkins-ci.org/releases + https://repo.jenkins-ci.org/releases @@ -82,7 +82,7 @@ org.jenkins-ci.main jenkins-core ${jenkins.version} - test + provided org.jenkins-ci.plugins.workflow @@ -121,7 +121,7 @@ javax.servlet javax.servlet-api ${jenkins.servlet.version} - test + provided org.jenkins-ci.plugins diff --git a/src/io/stenic/jpipe/plugin/SkipCommitPlugin.groovy b/src/io/stenic/jpipe/plugin/SkipCommitPlugin.groovy index 0fc0e15..741e3a0 100644 --- a/src/io/stenic/jpipe/plugin/SkipCommitPlugin.groovy +++ b/src/io/stenic/jpipe/plugin/SkipCommitPlugin.groovy @@ -3,7 +3,6 @@ package io.stenic.jpipe.plugin import io.stenic.jpipe.event.Event import org.jenkinsci.plugins.scriptsecurity.sandbox.RejectedAccessException import org.jenkinsci.plugins.workflow.steps.FlowInterruptedException -import jenkins.model.CauseOfInterruption.UserInterruption import hudson.model.Result class SkipCommitPlugin extends Plugin { @@ -43,7 +42,14 @@ class SkipCommitPlugin extends Plugin { // event.script.currentBuild.getRawBuild().setResult(Result.fromString(event.script.currentBuild.getPreviousBuild().result)) // } catch (RejectedAccessException e) {} - throw new FlowInterruptedException(Result.fromString(event.script.currentBuild.getPreviousBuild().result), true, new UserInterruption(event.script.env.BUILD_USER_ID)) + // Do not attach a UserInterruption cause: [skip ci] builds are SCM-triggered, + // so BUILD_USER_ID is null. UserInterruption stores the null user id and its + // hashCode() NPEs inside FlowInterruptedException.handle() during + // WorkflowRun.finish(), which aborts completion before + // RunListener.fireCompleted() runs. That skips the GitHub Branch Source + // final commit status, leaving the commit stuck on "pending". + // actualInterruption is false because nobody actually interrupted the build. + throw new FlowInterruptedException(Result.fromString(event.script.currentBuild.getPreviousBuild()?.result ?: 'SUCCESS'), false) } return true