Jenkins has a $CAUSE variable available to freestyle build jobs.
How can I access this or something similar in workflow?
My team makes use of it in email out
Looks like as of Jenkins 2.22 (JENKINS-41272), you can access the currentBuild.getBuildCauses() method to get an array of build causes. For example:
currentBuild.getBuildCauses()
environment { CAUSE = "${currentBuild.getBuildCauses()[0].shortDescription}" } steps { echo "Build caused by ${env.CAUSE}" }