So the purpose was to trigger a build on a Jenkins job after making a push to Gitlab Repo, Simple right?
After Downloading Gitlab pluging, setting up the project, still no luck. I get a 403 error.
With GitLab's Jenkins integration, you can effortlessly set up your project to build with Jenkins, and GitLab will output the results for you right from GitLab's UI.
GitLab Webhooks allows using Webhook notifications for all of the major lifecycle events in the software development process. It can trigger Webhooks for Code Push Events, Issue Changes, Comments, Merge Requests, Pipeline Events, Wiki Page Events, Deployment Events, Release Events, etc.
After some trial and error here is how I solved the issue:
Things I try:
Web hook fails when Jenkins Anonymous user does not have job/build permission
Need to document GitLab -> Jenkins authentication setup
How Do You Troubleshoot the GitLab Integration Webhook Error "Permission you need to have (but didn't) hudson.model.Hudson"?
This are the steps that I follow to fix this error
"Hook executed successfully but returned HTTP 403... You are authenticated as anonymous Groups that you are in: Permission you need to have (but didn't) hudson.model.Hudson.Read...which is implied by hudson.security.Permission.GenericRead..."
Go to Jenkins>Manage Jenkins>configuration
go to the Gitlab section and make sure is like so:
After setting up all this test your connection and make sure is successfull.
On your Jenkins project go Configure > Build Triggers and select
Build when a change is pushed to Gitlab. Gitlab webhook URL...
also, make sure to generate the token in advanced settings
Now in Gitlab go to your Project>Settings>Integrations
paste the URL you got in your Jenkins project, as well as the token generated in the Gitlab Build Triggers section, remove ssl verification
Now hit save and test your hook
you should get 200 success message on Gitlab and on Jenkins a triggered Job:
If that's not the case and you still get the 403, This are things you can do:
in Gitlab add a Jenkins user to your project (the one you're trying to get the webhook triggered from). This time it should work!!!
Troubleshooting
If it still not working another helper you can use is to add a logger to Jenkins go to Jenkins > Manage Jenkins > System log
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With