Created
April 15, 2019 19:59
-
-
Save fmarot/c8ad900b866ea1084ed1e34d5291ff9e to your computer and use it in GitHub Desktop.
do not take this code as-is because I just copy-pasted it from an old test and do not really know anymore if it works correctly. It may help though...
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
def userIdCause = currentBuild.rawBuild.getCause(hudson.model.Cause$UserIdCause) | |
boolean buildTriggeredManually = (userIdCause != null); | |
//boolean buildIsNightly = userIdCause.toString().toLowerCase().contains("trigger") || currentBuild.rawBuild.getCauses().get(0).toString().contains("BranchIndexingCause") | |
def buildIsNightly = false | |
currentBuild.upstreamBuilds?.each { b -> | |
echo "Upstream build: ${b.getFullDisplayName()}" | |
buildIsNightly = true | |
} | |
//def specificCause = currentBuild.rawBuild.getCause(hudson.model.Cause$UserIdCause) // must be set to null once used because it is not serializable | |
echo "userIdCause = ${userIdCause}, buildTriggeredManually = ${buildTriggeredManually}, buildIsNightly = ${buildIsNightly}" // #debug |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment