O'Reilly logo

Continuous Integration, Delivery, and Deployment by Sander Rossel

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Branch scripts

We have talked about branching before, but it is not until now that its use becomes apparent. Using multibranch pipelines, you can have a different build strategy per branch. For example, you probably want to build, test, report, and SonarQube your development branch, but you want to build, minify, test, and release your production branch. One option is to have a different Jenkinsfile in each branch. However, that makes it a little harder for Git to merge branches and you will always have an additional merge branch.

Another method is checking out what branch you are working in using the BRANCH_NAME environment variable and act based on that:

stage('Test Script') {    echo env.BRANCH_NAME    if (env.BRANCH_NAME == 'master') { echo ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required