Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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.

like image 517
Varyanica Avatar asked Jul 05 '10 11:07

Varyanica


People also ask

How do I run multiple jobs in Jenkins?

Use mulijob in the following way: When creating new Jenkins jobs you will have an option to create MultiJob project. In the build section, this job can define phases that contain one or more jobs. All jobs that belong to one phase will be executed in parallel (if there are enough executors on the node)


1 Answers

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.

like image 63
Sean Patrick Floyd Avatar answered Sep 28 '22 09:09

Sean Patrick Floyd