2
votes
curl -X POST http://xxx.yyy.zzz:5555/job/job-name/build --user john-devops-jenkins:11df3ed41129c5c7da1518e9c3149896de -H 'Jenkins-Crumb:31827a74a160347a641c87ddbc8e3b6e'

The above curl code with a post request is absolutely working fine in triggering the Jenkins build.

Tried:

Error: No valid crumb was included in the request

No luck still, How to configure bitbucket hook to container header information of crumb or how to pass it via url without relying on third party plugins?

1

1 Answers

2
votes

After a day of effort and brainstorming of how curl requests execute, finally resolved this issue by configuring bitbucket webhook as below:

http://jenkins-username:jenkins-password@jenkins-url:5555/job/job-name/build?crumb=crumb_token.

Hope it helps, many questions are unanswered and all are suggesting to use third party or generic-web-hooks and so on.

The CRUMB_TOKEN is nothing but AUTHENTICATION_TOKEN which we generate through Jenkins configuration

Follow these steps below to get authentication token:

  • Log in to Jenkins.
  • Click your name.
  • Click Configure.
  • Click Show API Token.

Do not get confuse with this URL: JENKINS_URL/job/policy-vault/build?token=TOKEN_NAME which is mentioned next to Trigger builds remotely input option

The correct URL which should be configured to build remotely is as below:

http://jenkins-username:[email protected]:5555/job/project-id/build?crumb=AUTHENTICATION_TOKEN

The Webhooks should also be configured from Bitbucket

Settings -> Repository Settings -> Webhooks

Title: PROJECT-XYZ-HOOK

URL: http://jenkins-username:[email protected]:5555/job/project-id/build?crumb=AUTHENTICATION_TOKEN