I want to trigger a Jenkinsjob every 2nd Tuesday. What I learned so far, is that this is not possible that easy. So I was trying something like this:
stage('Setup build schedule') {
properties([
pipelineTriggers([
cron('0 20 * * 2')
])
])
}
def build_number = env.BUILD_NUMBER as int
if ((build_number % 2) == 0) {
...
}
which is okay. But sometimes i also want to trigger this Multibranch-Pipeline Job by hand. Is it possible to set a variable only during the cron triggered start? Then I can check if this variable is set, and if not I know it is triggered by handy and proceed that way?
You are looking for something similar to BUILD_CAUSE.Jenkins pipeline doesn't supports cause directly. There is an article link below. You can use the BUILD_CAUSE variable inside the pipeline script to set your variables.
Build Cause Jenkins Pipeline
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With