multibranch-pipeline
Jenkins – abort running build if new one is started
With Jenkins script security many of the solutions here become difficult since they are using non-whitelisted methods. With these milestone steps at the start of the Jenkinsfile, this is working for me: def buildNumber = env.BUILD_NUMBER as int if (buildNumber > 1) milestone(buildNumber – 1) milestone(buildNumber) The result here would be: Build 1 runs and … Read more
“Build Periodically” with a Multi-branch Pipeline in Jenkins
If you use a declarative style Pipeline and only want to trigger the build on a specific branch you can do something like this: String cron_string = BRANCH_NAME == “master” ? “@hourly” : “” pipeline { agent none triggers { cron(cron_string) } stages { // do something } } Found on Jenkins Jira