Skip to content

Instantly share code, notes, and snippets.

@alfaproject
Created April 15, 2015 15:41
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save alfaproject/473d3541367d99662b4d to your computer and use it in GitHub Desktop.
Save alfaproject/473d3541367d99662b4d to your computer and use it in GitHub Desktop.
Bamboo UserScript to automate builds
// ==UserScript==
// @name Bamboo Builder
// @namespace cherrytech
// @version 0.1
// @author Joao Dias <joao.dias@cherrygroup.com>
// @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