Created
September 29, 2021 22:08
-
-
Save ipleten/a5a94a53491a2c299c6f7c9f11333684 to your computer and use it in GitHub Desktop.
Set labels on Jenkins steps.
This file contains 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 org.jenkinsci.plugins.workflow.actions.LabelAction; | |
import org.jenkinsci.plugins.workflow.cps.CpsThread; | |
pipeline { | |
agent any | |
stages { | |
stage('Hello') { | |
steps { | |
script { | |
try { | |
echo "do stuff" | |
} | |
finally { | |
// context.get(FlowNode.class).addAction(new LabelAction(StringUtils.left(label, MAX_LABEL_LENGTH))); | |
CpsThread.current().head.get().addAction(new LabelAction("Pipeline aborted, you silly!")) | |
} | |
} | |
} | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment