Hudson: start a list of jobs using Groovy console

Recently I wrote how to get a list of failed jobs in Hudson.

Rob Whitlock asked how to restart that list.

Here is the code:


joblist = hudson.model.Hudson.instance.items.findAll{job -> job.isBuildable()}  

startServer = "admin computer"
startNote   = "bulk start"
cause = new hudson.model.Cause.RemoteCause(startServer, startNote)
joblist.each{run -> run.scheduleBuild(cause)}

In the first line I just get a list of jobs from somewhere.

The interesting part is line 6: here I start the build or more precise – reschedule it. Hudson starts it somewhere in the future.

There is a scheduleBuild() method without argument, but it is deprecated. That’s why I create a ‚cause‘ first. So the build knows why it is run. Usually you have a „started by user XYZ“ or „started by upstream project“ here.

Advertisements
Explore posts in the same categories: en, Hudson

Schlagwörter: , , ,

You can comment below, or link to this permanent URL from your own site.

3 Kommentare - “Hudson: start a list of jobs using Groovy console”

  1. EJC Says:

    Won’t that just restart all jobs?

  2. naresh Says:

    Hi,

    How to the cause of the jobs failure basically the reason why jenkins jobs is getting failed.

    Regards,
    Naresh.


Kommentar verfassen

Trage deine Daten unten ein oder klicke ein Icon um dich einzuloggen:

WordPress.com-Logo

Du kommentierst mit Deinem WordPress.com-Konto. Abmelden / Ändern )

Twitter-Bild

Du kommentierst mit Deinem Twitter-Konto. Abmelden / Ändern )

Facebook-Foto

Du kommentierst mit Deinem Facebook-Konto. Abmelden / Ändern )

Google+ Foto

Du kommentierst mit Deinem Google+-Konto. Abmelden / Ändern )

Verbinde mit %s


%d Bloggern gefällt das: