MultiBranch Webhook Trigger

Hi Community,
Our Setup - We have 6 branches in our Github Repo and we have one multi branch pipeline for each branch(this setup is due to separation of Duties) setup in Jenkins.

we are setting up webhook for this Multi branch jobs and to start with we want this webhook to be triggered only on specific branches and achieved this with Webhook Token. But the problem is all the jobs starts to scan when we push code to the any one branch where we have webhook enabled. Is there a way to stop scanning of all jobs?

Thanks in Advance

Hi @anandsecured. I highly doubt that there is a way to only scan the one job applicable to the branch that was modified because these are all in the same repository. GitHub only allows webhooks to be defined at the repository level, so a change to any branch will result in the hook being sent to all jobs configured with that hook. Jenkins will have to scan for changes in each job to see if it needs to be rebuilt.

Is there also an issue that Jenkins is starting a new build for each job in addition to re-scanning the repository whenever the hook is received? If a new build is started as well, then that’s something that can likely be fixed. But just doing a repository scan is likely a necessary step.

Hi @mtughan, thanks for your response.

Yes, In addition to re scanning, new build is getting triggered if there is a new commit in the branch which is not built yet. Can you please tell me how we can fix this?

Thanks in Advance

Anand R

Sorry, I’m not sure I understand: if one of the jobs is pointed to a specific branch, but that job has not been built yet, you don’t want it to build? In that scenario, I’d be looking at disabling the job altogether until you’re ready for it; don’t rely on the webhook not building it.

Ideally, if the branch was re-scanned but the last commit in the branch was already built, a new build should not be started. If the last commit was not built, I would expect a build to be started. If you’re looking for something different than that, we’d need to know more about your scenario to be able to advise better.