Skip to content

Instantly share code, notes, and snippets.

@joseraya
Created October 5, 2013 08:19
Show Gist options
  • Star 17 You must be signed in to star a gist
  • Fork 4 You must be signed in to fork a gist
  • Save joseraya/6838271 to your computer and use it in GitHub Desktop.
Save joseraya/6838271 to your computer and use it in GitHub Desktop.
Configure Bitbucket hook for jenkins

In order to configure the bitbucket hook we need two things: The user's API Token and the project token. In order to retrieve the first one whe should click on our username (on the top right corner of the page), click on configure and then click on "Show API Token". This API token will be used as password for our user.

For the project's token we need to go to the job configuration (/job/{job-name}/configure), "build triggers" and enable "trigger remote builds" and, there, input some random text as token.

Once we have these two tokens we can go to bitbucket, repo administration, hooks section, and add a new jenkins hook that we will configure like:

  • Endpoint: http://{username}:{APIToken}@{hostname}/{prefix_if_you_have_one}
  • Module name: Whatever (I usually leave this one blank)
  • Project name: The job name
  • Token: The project token

If you want to manually test the hook you can do the following:

curl -u {username}:{APIToken} -X POST http://{hostname}{/prefix_if_you_have_one}/job/{project_name}/build?token={project_token}

This should trigger a build in your jenkins server.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment