Pull Request Validation Between Jenkins and Bitbucket

In the end of this tutorial, your Jenkins will execute every Bitbucket open pull request and post a comment with the commit number, link to console output, link to coverage report.

Go to my page and fork the master version of shell script.

  • Your comments on bitbucket will be just like this:


Install Gitbucket plugin on your Jenkins and Create a new job on your Jenkins and select the option:

Build multi-configuration project
  • Settings Screen

Inside GitBucket config, select This build is parameterized and create one parametrized value for each variable above:

* OWNER = bitbucket owner
* BUCKET_API_V1_URL = bitbucket.org/api/1.0/repositories
* BUCKET_API_V2_URL = api.bitbucket.org/2.0/repositories
* REPO = $repository
* JENKINS_URL = your_jenkins_url.com
* LANGUAGE = program language (python or ruby)

”Source Code Management”

Select ”Git” and insert your bitbucket link with this pull request script.

”Build Triggers”

Select ”Poll SCM” and insert your crontab to Jenkins validade with bitbucket if there is a open PR. In my project, the Jenkins validate every 5 minutes.

H/5 * * * * 

”Configuration Matrix”

Create a ”User Defined Axis” with the ”name: repository” and on the values, insert your Bitbucket repository name.


Include this script on the ”Execute Shell”

  • Configure Code analisys

”Post Build Actions”

> On Python

Activate the Cobertura Plugin ”Publish cobertura coverage Report” and insert the location of the coverage report, on .xml format.


> On Ruby

The ruby coverage will be generated on HTML format.

This script will bee function only if you are using python or ruby language and configure coverage report on your tests.

VERY Important Note

ci.sh is the file when I execute my environment configuration to run the tests.
## Your PYTHON .html coverage report MUST be on this path:
## Your RUBY .html coverage report MUST be on this path:

Thanks for your attention and be welcome to send me a message if you have any question or improvement to this post.

See Ya