Renjith
Renjith

Reputation: 1154

Unable to filter the github webhook trigger in jenkins

I have followed the link given below to trigger my jenkins pipeline job only when a push occurs on master branch. https://wiki.jenkins.io/display/JENKINS/Generic+Webhook+Trigger+Plugin

Configuration in github: Github Webhook configuration

To filter according to the payload 'ref' tag, optional filter is set in jenkins pipeline job. Assigning ref value to 'ref' variable

Then i applied optional filter on 'ref' variable, to allow only master branch Filter 'ref' variable

Finally a token filter is added, that is unique to my repository Token filter

Token filter works as expected, but the filter on ref variable is not having any impact on the pipeline job. Job will be triggered irrespective of what value is given on the regular expression.

Eg. Job is getting triggered even if I delete a tag! 'ref' tag when a tag was deleted

I am not able to understand this behavior, neither I think that I am missing something in the configuration. Your help will be highly appreciated.

Upvotes: 3

Views: 4995

Answers (1)

VonC
VonC

Reputation: 1324347

Since you are using a token, that might explain why the job is always triggered:

Trigger only specific job

When using the plugin in several jobs, you will have the same URL trigger all jobs. If you want to trigger only a certain job you can:

  • Use the token-parameter and have different tokens for different jobs. Using only the token means only jobs with that exact token will be visible for that request. This will increase performance and reduce responses of each invocation.
  • Or, add some request parameter (or header, or post content) and use the regexp filter to trigger only if that parameter has a specific value.

In your case, try and use only the un:pw (username/password) in your URL, without a token, to see of your Optional Filter applies.

Upvotes: 1

Related Questions