Renaming job in jenkins/hudson

You can rename selected job through jenkins UI by following these steps:

job>configure>Advanced Project Options>Display Name

Other way is to rename the directory on the Jenkins/hudson server and then restart the Jenkins.


For Quick understanding I used some screenshots:

I used Jenkins version: 2.148

Step 1:

On home screen / Job list just click on job option.

enter image description here

OR

Just open Job details you will see left side option for rename.

enter image description here

Step 2:

Enter new name and just click on Rename button

enter image description here


Just for the sake of completeness, want to mention the update of Hudson job name using Groovy script console:

// Groovy script to rename job in Hudson
import hudson.model.*;

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

(Hudson.instance.items.findAll { job -> job.name =~ JOB_PATTERN }).each { job_to_update -> 
    println ("Updating job " + job_to_update.name);
    def new_job_name = job_to_update.name + NEW_PART; //Append new part to the job name
    println ("New name: " + new_job_name);
    job_to_update.renameTo(new_job_name);
    println ("Updated name: " + job_to_update.name);
    println("="*80);
}

Rather helpful if you need to update several dozens of jobs at the same time.

Note: The following code will not work:

job_to_update.name = new_job_name;
job_to_update.save();

Setting the name of the job to new and saving configuration will not rename current job, but create a copy of the job configuration with a new name. Also, in this case, there might be broken references, so Hudson will need to have configuration reloaded.

Tags:

Hudson

Jenkins