Hi everyone, I’ve searched for similar issues but most of them unanswered/didn’t worked for me.
I have IIS deploy setup in Jenkins which is works fine by manual trigger. Then I configured GitLab Webhook to trigger build event based on branch name.
My problem was when I use filter branches by name option, gitlab webhook sents successful request but it does not triggered anything on Jenkins.
Hello and welcome to this community, @FatihCeylan.
The issue you’re encountering with Jenkins not triggering builds from GitLab webhook events when using the “Filter branches by name” option, but working correctly with “Filter branches by regex,” suggests a potential mismatch or specificity issue in how branch names are being interpreted or matched by Jenkins.
When using “Filter branches by name,” ensure that the branch names are exactly as they appear in your repository, including any case sensitivity. Jenkins and GitLab might handle branch names differently, especially regarding case sensitivity or hidden characters (like whitespace at the end of the branch name).
On the other hand, “Filter branches by regexp” provides more flexibility and can inadvertently bypass subtle mismatches by using a pattern that matches the intended branch names, regardless of case or additional characters.
Here are a few ideas to try and troubleshoot your issue:
Double-check the branch names listed in the “Filter branches by name” field. Make sure they exactly match the branch names in GitLab, including case sensitivity and absence of trailing spaces.
Inspect the webhook payload sent from GitLab to Jenkins. Verify that the branch names in the payload match exactly with what you’ve configured in Jenkins. This can help identify if there’s a discrepancy in how branch names are being sent or interpreted.
Check the Jenkins system log for any messages related to the webhook event processing. Jenkins might log information about why a particular event did not trigger a build.
Make sure that the GitLab plugin and any related plugins in Jenkins are up to date. Sometimes, bugs (in this case, bugs related to webhook processing) are fixed in newer versions of the plugins.
If case sensitivity is an issue, consider using a regex that matches the branch name regardless of case, e.g., (?i)branchname where branchname is your actual branch name, and (?i) makes the match case-insensitive.
As a workaround, if specific branch names are not working and you suspect a bug, continue using the regex option. Craft regex patterns that precisely match your branch naming conventions to minimize the risk of unintended builds.
Thank you for response,
As you migh know Filter branches by name options comes from directly gitlab branch source and as you mentioned it gaves warning in case of any case mismatch.
You can see demonstration below image;
Also checked jenkins system log and it gaves error like this;
WebHook called with url: /project/Backend_GCrm
Jul 09, 2024 12:03:56 PM INFO com.dabsquared.gitlabjenkins.trigger.handler.AbstractWebHookTriggerHandler handle
Source branch fatih or target branch master is not allowed
strangely there’s no error and everything works fine if I use Filter branches by regex option.
I’ve searched for this error around internet but nothing came up with solution yet.
I’ll updating this post if I’ve found a solution.