Skip to content

Instantly share code, notes, and snippets.

@ipleten
Created September 29, 2021 22:08
Show Gist options
  • Save ipleten/a5a94a53491a2c299c6f7c9f11333684 to your computer and use it in GitHub Desktop.
Save ipleten/a5a94a53491a2c299c6f7c9f11333684 to your computer and use it in GitHub Desktop.
Set labels on Jenkins steps.
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