Skip to end of banner
Go to start of banner

Configuring different build jobs for different branches

Skip to end of metadata
Go to start of metadata

You are viewing an old version of this page. View the current version.

Compare with Current View Page History

Version 1 Next »

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

  • No labels