Created
April 27, 2015 09:01
-
-
Save swissmanu/b261341a03f90a2cd332 to your computer and use it in GitHub Desktop.
Greasemonkey: Show Build Status in Pull Request Overview in Atlassian Stash
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// ==UserScript== | |
// @name Stash: PR Overview Build Status | |
// @namespace me.alabor | |
// @include https://mystash/projects/PROJECT/repos/REPOSITORY/pull-requests | |
// @include https://mystash/projects/PROJECT/repos/REPOSITORY/pull-requests?state=open | |
// @version 1 | |
// @grant none | |
// @require http://code.jquery.com/jquery-1.11.2.min.js | |
// ==/UserScript== | |
var stashUrl = 'https://mystash' | |
, rows = $('tr.pull-request-row'); | |
rows.each(function() { | |
var row = this | |
, branch = $('td.source span.name', row).text() | |
, url = stashUrl + '/rest/api/1.0/projects/PROJECT/repos/REPOSITORY/branches?filterText=' + branch; | |
$.get(url, function(response) { | |
var lastCommit = response.values[0].latestCommit; | |
$.get(stashUrl + '/rest/build-status/1.0/commits/stats/' + lastCommit, function(response) { | |
// Colors: http://colors.findthedata.com/saved_search/Pastel-Colors | |
if(response.failed > 0) { | |
$(row).css('background-color', 'rgba(255,105,97,0.3'); | |
} else if(response.inProgress > 0) { | |
$(row).css('background-color', 'rgba(207,207,196,0.3'); | |
} else if(response.successful > 0) { | |
$(row).css('background-color', 'rgba(119,190,119,0.3)'); | |
} | |
}); | |
}); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment