Skip to content

Instantly share code, notes, and snippets.

@coorasse
Last active February 6, 2018 12:36
Show Gist options
  • Star 7 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save coorasse/706d9456fcbe359744d1 to your computer and use it in GitHub Desktop.
Save coorasse/706d9456fcbe359744d1 to your computer and use it in GitHub Desktop.
Bitbucket Codeship PullRequest integration script
$(function() {
var bitbucket_project_name = 'YOUR BITBUCKET PROJECT_NAME LIKE coorasse/airesis';
var codeship_project_code = 'YOUR CODESHIPO PROJECT UUID CODE (look for it in the badge instructions page or general settings page)';
var regexp = new RegExp("^https://bitbucket.org/" + bitbucket_project_name + "/pull-request/","g");
if ((regexp).test(window.location.href)) {
var branch = $('dd.unabridged a').first().html();
var url = 'https://codeship.com/projects/'+codeship_project_code+'/status?branch='+branch;
var row = $('<div></div>')
var column1 = $('<dt>Codeship</dt>');
var column2 = $('<dd><img src="'+url+'"/></dd>');
row.append(column1);
row.append(column2);
$('.clearfix.description').after(row);
}
});
@coorasse
Copy link
Author

I wrote this script since the only way to integrate Codeship and Bitbucket, until today, was to follow this guide.
I didn't want to install an Heroku app just to see a badge on my Pull Request page on Bitbucket and since I already had plugin for my browser ready to inject javascript in pages I wrote this simple script.

  • fill in the bitbucket project name (with your username included)
  • fill in the codeship project UUID code (the one you see in the badge url or the codeship project general settings page)
  • inject the script in bitbucket page with your favourite plugin
  • see your badge!

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