Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

With the Bitbucket Branch Source plugin, you can configure different build jobs for different branches from the Jenkinsfile for multibranch projects. The sample Jenkinsfile below specifies different build jobs for branches, develop and production.

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 this, see the Jenkins doc  build-a-multibranch-pipeline-project