Varyanica
Varyanica

Reputation: 409

Hudson: Running all jobs in a view by pressing one button

Is there a way to run all jobs in one hudson's view by pressing just one button? Thanks.

Upvotes: 6

Views: 2228

Answers (2)

Sean Patrick Floyd
Sean Patrick Floyd

Reputation: 298818

Update: here is the solution

Edit your view's description and paste this code into it:

<script type="text/javascript">
<!--
function triggerBuilds(obj){
    obj.responseText.evalJSON()['jobs'].each(
            function(i){
                new Ajax.Request(i['url']+'build',{method:'GET'});
            }
    );
}

function buildAll(){
    new Ajax.Request(
            document.URL.replace(/[\W]+$/,'') + '/api/json',
            {
                onSuccess : triggerBuilds,
                method : 'GET'
            }
    );
}

//-->
</script>
<a href="javascript:buildAll();void(0)">Build all Jobs in this view</a>

This will create a link that builds all jobs in the current view using hudson's JSON api. (Only works from the view, if you want to use it from somewhere else you have to change the relative URLs).

(this solution relies on prototype which is present in current versions of hudson, but I don't know how long it has been present, so this may not work for older versions)

or create a bookmarklet for this URL:

javascript:var%20f=function(obj){obj.responseText.evalJSON()['jobs'].each(function(i){new%20Ajax.Request(i['url']+'build',{method:'GET'});});};new%20Ajax.Request(document.URL.replace(/[\W]+$/,'')+'/api/json',{onSuccess:f,method:'GET'});void(0)

in your bookmark menu and execute it on any hudson view you like


Edit: I have elaborated on this answer on my weblog.

Upvotes: 2

VonC
VonC

Reputation: 1323303

You could define a parent Job and use it to launch all the children job (maven jobs with a dependency tree).

Combined with the Join Plugin, you can even set a Job when all previous jobs are completed.

Upvotes: 0

Related Questions