Preventing builds from getting triggered when creating a new multibranch Pipeline or Organization Folder


  • When a new GitHub Organization job is created, all repos are scanned and builds are triggered right away. Is there any way to prevent these automatic builds?
  • I want to control whether a stage should be executed or not based on the triggered events.



The best way is to install Branch API 2.3.0 and Basic Branch Build Strategies 1.3.0. A new option is added to skip initial build on branch indexing:

If you can’t install the plugins for some reason, go to the GitHub Org configuration, clear the field Branch names to build automatically.

After saving the job, you can add .* to re-enable builds.


You can also control when a stage should be executed. In the following example, the deployment stage is skipped unless the build is triggered by a Github push event.

pipeline {
    agent none
    stages {
        stage('Example Build') {
            steps {
                echo 'Hello World'
        stage('Example Deploy') {
            when {
                expression {
                    currentBuild.buildCauses.toString().contains("Push event to branch")
            steps {
                echo 'Deploying'

Tested product/plugin versions


Have more questions?


Please sign in to leave a comment.