I have a project created and configured on private Gitlab v9.0 instance. I have imported this project on Jenkins v2.46.1, the connection with gitlab is successful. Afterwards, I tried to configure build trigger on push event from repo in gitlab. I have generated secret token for it on jenkins and added a webhook with Gitlab CI URL and secret token when I tried to test the webhook it returned me below exception
Hook executed successfully but returned HTTP 403 <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/> <title>Error 403 anonymous is missing the Job/Build permission</title> </head> <body><h2>HTTP ERROR 403</h2> <p>Problem accessing /project/tapp-builder-service. Reason: <pre> anonymous is missing the Job/Build permission</pre></p><hr><i><small>Powered by Jetty://</small></i><hr/> </body> </html>
Can anyone please help me solving this?
You can trigger a build in Jenkins when you push code to your repository or create a merge request in GitLab. The Jenkins pipeline status displays on merge requests widgets and on the GitLab project's home page.
Go to Manage Jenkins -> Configure System and scroll down to the 'GitLab' section. Write a custom connection name, enter the GitLab server URL in the 'GitLab host URL' field and click Add -> Jenkins button. Then, fill required fields as shown below with the Jenkins Access API Token which we created in GitLab before.
On the Global Configuration page in Jenkins, in the GitLab configuration section, supply the GitLab host URL, e.g. https://your.gitlab.server. Click the 'Add' button to add a credential, choose 'GitLab API token' as the kind of credential, and paste your GitLab user's API key into the 'API token' field.
The best way to configure this is
Require authorization for /project endpoint Copy userid and API key for a Jenkins user who has authorization to run the job
Create a webhook on GitLab to trigger the job
Then use HTTP basic auth (Below format):
http://user:apikey@gitlab/project/jobname
You can either add a special user in Jenkins for this and configure the Webhook in GitLab accordingly or you can uncheck the checkbox "Enable authentication for '/project' end-point" in the GitLab section of the global Jenkins configuration. But this should be unchecked by default.
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