I'm passing a webhook request from azure devops to my local jenkins. It's passing Nginx on OpnSense.
I read it does not give any clear message when the definition is invalid.
This is part of the request url: "/generic-webhook-trigger/invoke?token=mytoken/git/notifyCommit?url..."
The webhook url definition on devops is "/generic-webhook-trigger/invoke?token=mytoken", but it's also adding "/git/notifyCommit?url..." which creates a invalid url.
So i'm trying to remove "/git/notifyCommit?" from the url and replace it with "&".
But whatever i try to define as a URL rewriting rule (and add it to the location), it does not do anything, passing the original url.
Do you have any suggestions on the used parameters for the URL rewriting rule?
additionally I've also looked at the nginx.config and it validated with following test:
location = /git/notifyCommit {
rewrite ^/git/notifyCommit?$ /somePage break;
But it still did not rewrite the url at all.
So I figured it out:
Copilot first suggested to use request url: "/generic-webhook-trigger/invoke?token=mytoken"
this was wrong because it created an invalid url.
It seems that you cannot rewrite an invalid url with Nginx on Opnsense. So it could never work.
I changed the devops webhook to url: "/generic-webhook-trigger/invoke/token/mytoken"
Problem here is that jenkins accepts this format: http://JENKINS_URL/generic-webhook-trigger/invoke?token=TOKEN_HERE
So I still had to rewrite the now valid url from devops webhook.
used the following in nginx on opnsense:
location:
URL pattern: /generic-webhook-trigger/invoke
URL rewriting: MyRule
URL Rewriting:
Description: Myrule
Original URL Pattern: ^/generic-webhook-trigger/invoke/token/([^/]+)/git/notifyCommit$
New URL Pattern: /generic-webhook-trigger/invoke?token=$1
Flag: stop processing rules
Now the pipeline in Jenkins gets triggered when commiting a change to my Azure Devops Branch.
Still needs a bit of tweaking but at least I got it working.