0

I have git monorepo repository with multiple projects inside. So I have following structure of Jenkinsfiles in this repo:

|-Jenkinsfile (root one)
|-projectA
| |-Jenkinsfile (for projectA)
| |- ... (project files)
|-projectB
  |-Jenkinsfile (for projectB)
  |- ... (project files)

In main root Jenkinsfile I have logic to check PR changed files and then trigger projects pipelines when files in specific project were changed.

And I have Webhook.

My problem is that all those 3 pipelines are triggered by Webhook. So my current state is:

  1. I change something in projectA and create PR
  2. Webhook triggers all pipeliens: root, projectA and projectB
  3. root pipeline notices that changes were made on projectA and triggers projectA pipeline

So in runs I have:

  • one run of root pipeline triggered by webhook
  • one run of projectA pipeline triggered by webhook
  • one run of projectB pipeline triggered by webhook
  • one run of projectA pipeline triggered by upstream

And I want to have:

  • one run of root pipeline triggered by webhook
  • one run of projectA pipeline triggered by upstream

I cannot change webhook nature because it's monorepo so its sent every time anyone does anything in any project. So I need to prevent projectA and projectB pipelines from reacting on incoming webhook.

Does anyone know how to do it?

Mateusz
  • 1,149
  • 1
  • 16
  • 33

1 Answers1

1

I found a solution:

multibranchPipelineJob(...) {
            branchSources {
                branchSource {
                    source {
                        ...
                    }
                    strategy {
                        allBranchesSame {
                            props {
                                suppressAutomaticTriggering()
                            }
                        }
                    }
                }
            }
            ...
        }

This setting prevents webhook triggers to start job.

Mateusz
  • 1,149
  • 1
  • 16
  • 33