Skip to content

Instantly share code, notes, and snippets.

@epishan
Last active August 24, 2016 11:14
Show Gist options
  • Select an option

  • Save epishan/010c43227200eeb29c25f833c553dd2c to your computer and use it in GitHub Desktop.

Select an option

Save epishan/010c43227200eeb29c25f833c553dd2c to your computer and use it in GitHub Desktop.

Revisions

  1. epishan renamed this gist Aug 24, 2016. 1 changed file with 0 additions and 0 deletions.
    File renamed without changes.
  2. epishan created this gist Aug 24, 2016.
    20 changes: 20 additions & 0 deletions Rename job
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,20 @@
    // Groovy script to rename job in Hudson
    import hudson.model.*;

    def JOB_PATTERN = ~/^GO.*.deploy_container.staging*$/; //find all jobs starting with "MY_JOB".
    def NEW_PART = "_NEW"

    (Hudson.instance.items.findAll { job -> job.name =~ JOB_PATTERN }).each { job_to_update ->
    if (job_to_update.name =~ "GO.bob_api.*") {
    return;
    }
    else {
    println ("Updating job " + job_to_update.name);
    def new_job_name = job_to_update.name.replaceFirst("build", "build_binary");
    println ("New name: " + new_job_name);
    job_to_update.renameTo(new_job_name);
    println ("Updated name: " + job_to_update.name);
    println("="*80);
    }
    }