Created
June 9, 2022 14:53
-
-
Save pwalkr/304017515e7be403c3b418f39a19be0c to your computer and use it in GitHub Desktop.
Abort build on indexing trigger
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import hudson.model.Result | |
import org.jenkinsci.plugins.workflow.steps.FlowInterruptedException | |
// Callable as a step, defined in vars/ | |
void call() { | |
if (this.isBranchIndexingCause()) { | |
echo "ABORTED: $message" | |
throw new FlowInterruptedException(Result.NOT_BUILT) | |
} | |
} | |
// Based on https://stackoverflow.com/a/56775578 | |
@NonCPS | |
Boolean isBranchIndexingCause() { | |
return currentBuild.rawBuild.getCause(jenkins.branch.BranchIndexingCause) ? true : false | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment