1
  1. when I configure the web-hooks from bitbucket server. Is there any configuration, I should configured in Jenkins server? eg : special permission for anonymous users.. Because when I try to test the connection, I am receiving a 403 error. Please see the error details below.

enter image description here

  1. In the webhook, Secret(Optiona) , The string is used to verify data integrity between Bitbucket and your endpoint. Is there anything I need to configure in my endpoint which is a Jenkins server. How the integrity checking is working here ?

<html>
<head>
<meta http-equiv="Content-Type" content="text/html;charset=utf-8"/>
<title>Error 403 No valid crumb was included in the request</title>
</head>
<body><h2>HTTP ERROR 403 No valid crumb was included in the request</h2>
<table>
<tr><th>URI:</th><td>/job/api-xxxxxx/job/stg/job/xxxxxxxxxxx/</td></tr>
<tr><th>STATUS:</th><td>403</td></tr>
<tr><th>MESSAGE:</th><td>No valid crumb was included in the request</td></tr>
<tr><th>SERVLET:</th><td>Stapler</td></tr>
</table>
<hr><a href="http://eclipse.org/jetty">Powered by Jetty:// 9.4.27.v20200227</a><hr/>

</body>
</html>

Reference : https://confluence.atlassian.com/bitbucketserver/managing-webhooks-in-bitbucket-server-938025878.html

UtpMahesh
  • 410
  • 10
  • 25

1 Answers1

1

I'm also facing the same error. I can suggest you the workaround which will work but I can't assure that it's secure (using Token Based Authentication).

As the 403 status code clearly states that this URL exists but your user isn't authorized to access the URL.

Below is how you can make it work:

Navigate to Jenkins > Manage Jenkins > Configure Global Security > Select Matrix based security under Authorization and check options below for Anonymous user:

---------------------------------------------
| User       | Overall | Job                |              
|--------------------------------------------                                           
| Anonymous  | Read    | Read, Workspace &  |
| user       |         | Build              |                                                           
--------------------------------------------

and save the changes.

After that Navigate to your job in Jenkins > Configure > Build triggers > And Select "Trigger builds remotely (e.g., from scripts)"

After selecting this, one text box will appear with tag "Authentication Token" where you can generate a token. Enter some text into the text box to generate the token. For example you entered OathToken.

Now navigate to Bit Bucket > Repository Settings > Webhook > Edit and enter the URL as follows:

JENKINS_URL/view/JenkinsViewName/job/JenkinsJobName/build?token=OathToken

In the above URL replace following:

JENKINS_URL - With you original Jenkins url (http://Domain/)
JenkinsViewName - With the view name in your Jenkins pipeline
JenkinsJobName - With the job name in your Jenkins pipeline
OathToken - With your original Token value

Click on Test connection now and it'll return you 201 status code and it'll trigger the build upon new push in the repository.

Again please consider your security preferences.