With the Bitbucket Branch Source plugin, you can configure different build jobs for different branches from the Jenkinsfile for multibranch multi-branch projects. The sample Jenkinsfile below specifies different build jobs for branches, development, develop and production.
Code Block |
---|
pipeline { agent any stages { stage('Build') { sh 'echo "Building project"' } stage('Test') { sh 'echo "Running unit tests"' } stage('Deliver for development') { when { branch 'development' } sh 'echo "This is only run for the development branch"' } stage('Deploy for production') { when { branch 'production' } sh 'echo "This is only run for the production branch"' } } } |
For more on how to do thisinformation, see the Jenkins doc Jenkins build-a-multibranch-pipeline-project document.