Created
April 15, 2015 15:41
-
-
Save alfaproject/473d3541367d99662b4d to your computer and use it in GitHub Desktop.
Bamboo UserScript to automate builds
This file contains hidden or 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 Bamboo Builder | |
// @namespace cherrytech | |
// @version 0.1 | |
// @author Joao Dias <[email protected]> | |
// @match http://bamboo.cherrytech.com/browse/* | |
// @grant GM_getValue | |
// @grant GM_setValue | |
// ==/UserScript== | |
var builds = GM_getValue('builds', 0); | |
var isRunMenuEnabled = function() { | |
return document.querySelector('#runMenuParentDisabled') === null; | |
} | |
var isCreateReleaseEnabled = function() { | |
return document.querySelector('.brs-create-version-button') !== null; | |
} | |
var runBranch = function() { | |
var runMenuItems = document.querySelectorAll('#runMenuParent .item-link'); | |
for (var i = 0; i < runMenuItems.length; i++) { | |
var runMenuItem = runMenuItems[i]; | |
if (runMenuItem.textContent === 'Run branch') { | |
runMenuItem.click(); | |
break; | |
} | |
} | |
} | |
if (isRunMenuEnabled() && !isCreateReleaseEnabled()) { | |
if (builds === 0 && confirm('Do you want to run this branch?')) { | |
// first run, and no previous builds | |
runBranch(); | |
builds++; | |
} else if (builds > 0) { | |
// if there is a build process going on, then keep going | |
runBranch(); | |
builds++; | |
} | |
} | |
console.log('Builds: ' + builds); | |
if (isCreateReleaseEnabled()) { | |
builds = 0; | |
} | |
GM_setValue('builds', builds); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment