Generic Webhook Trigger restriction on master branch

Hi Team ,

we are trying to implement “generic webhook trigger” instead of “poll SCM” for master branch only. Currently pipeline job is getting triggered for all the merged event for dev, qc and master, but aim is to restrict the pipeline job trigger when any merge event occur for master branch.
In operation filter, we have tried to filter the master branch with expression “$.ref/head/master” but its not working and not able to get the desired result.

Regards,
Ashish Jha

How are you triggering the job? I don’t think generic webhook has any concept of merged

Hi Halkeye,

We want to run the job only on master branch when the merge event occurs on master.

Request you to please provide the step so that we can restrict the job on lower dev and Qc branch.

let us know the parameter needs to be used to restrict on lower branch.

Regards,
Ashish Jha

Hi Halkeye ,

In the bit bucket repository, we have checked the merge on webhook however i have tried removing and unchecking it and then checked on push still with the below parameter unable to restrict it on dev and QC . Please suggest with the parameter to restrict the trigger on dev and QC .
We want to trigger the job only on master branch.

Regards,
Ashish Jha

Hi Halkeye ,
Please find the below parameter i am using to run the Jenkins pipeline job when changes occur in master branch.

Regards,
Ashish Jha

I’ve never used the generic webhook trigger. I would recommend using the Bitbucket integration so you can choose what events trigger a build. I personally use GitHub integration so can’t help much there either.

Hi Halkeye ,

Request you to please check if anyone else from your team can help on below query will be highly appreciated .

Regards,
Ashish Jha

People help here as they have time and interest. There isn’t a “team” that helps. There are individuals that give their time to assist other individuals. Their time is donated in hopes of helping others as they use Jenkins.

Since you’ve ignored the advice from @halkeye to use a higher level integration (Bitbucket), I would expect that he’s probably done helping you.

There are certainly organizations that offer commercial products based on Jenkins. There are certainly organizations that offer paid consulting on Jenkins implementations. If the help of individual volunteers is not enough to meet your needs, you can always consider paying one of those organizations to help you.

1 Like

Imho, I think that first line “variable” say about we can use our match from this window in our pipeline. It isn’t filter for webhook. It is a filter for match from webhook for your variable in pipeline.

Name of variable

  1. Assign a name to the ref variable

Expression

  1. Specify a regular expression to capture
    now your variable ref = refs/heads/main

Expression (at the end)

  1. Specify a regular expression for the branches for which you want to run jobs.

Text

  1. Compare the regular expression (allowed branches) with what is in your ref variable

Top right is a quote from the documentation. It provides an example for the develop branch and multiple feature branches.