Issue
I can have my master branch jobs run hourly like this:
String cron_string = BRANCH_NAME == "master" ? "@hourly" : ""
pipeline {
agent none
triggers { cron(cron_string) }
stages {
// do something
}
}
But I want some specific behavior for that hourly run- like only running certain stages for the hourly cron triggered run.
Is there any way to identify if a multibranch job was triggered by a cron schedule from inside the pipeline?
Solution
currentBuild.getBuildCauses()
should work.
https://opensource.triology.de/jenkins/pipeline-syntax/globals#currentBuild
Answered By - smelm