user1528958
user1528958

Reputation: 21

Jenkins multi-branch pipelines' other repo's jobs triggered with bitbucket webhook push

Using Jenkins 2.263.2, I configured Bitbucket webhook and Jenkinsfile (declarative jenkins pipeline).

When I push a commit to repo A, other multi-branch pipelines' jobs (i.e. pipelines for repo B-E) are triggered.

It seems that pushing to only repo A would trigger other pipelines.

I tried all of these:

triggers { 
   bitbucketPush()
}

Tried overriding Repository URL (https://github.com/jenkinsci/bitbucket-plugin#override-repository-url)

triggers { 
   bitbucketPush overrideUrl: 'https://bitbucket.org/xxx/repo-name'  
}

Tried adding property "Suppress Automatic SCM Trigger" to job configuration (https://stackoverflow.com/a/53769527)

enter image description here

What I'm observing is when unrelated repo's jobs are triggered, their repo's webhook request are not there, neither is Jenkins scan log for that repo.

enter image description here

enter image description here

Any ideas how to stop multiple unrelated Jenkins jobs to be triggered?

Upvotes: 0

Views: 974

Answers (1)

sweepchild
sweepchild

Reputation: 1

This is how i accomplished, hope it works for you too.

for pipelineJob

pipelineJob('pipeline-job-1') {

    configure { project ->
    
        project / 'properties' / 'org.jenkinsci.plugins.workflow.job.properties.PipelineTriggersJobProperty' / triggers / 'com.cloudbees.jenkins.plugins.BitBucketTrigger' {
            spec()
            overrideUrl('[email protected]:baz/repo.git')
        }
    }

    /// some codes

}

for multibranchPipelineJob

multibranchPipelineJob('my-multibranch-job1') {

 configure { project ->
        
        project / triggers / 'com.cloudbees.jenkins.plugins.BitBucketMultibranchTrigger' {
            spec()
            overrideUrl('[email protected]:baz/repo.git')
        }
    }

    /// some codes

}

Upvotes: 0

Related Questions