How to bulk rename jira projects using groovy script

Abhishek Rawat August 23, 2020

I am trying to bulk rename multiple jira projects. I have a list of current and the new name in a sheet. I am using the following script and it runs perfectly.

I do not know how to run it in a loop so that it picks each item from the old project name column of the excel and updates it with the name in new column in excel.
Here is the code that I am using:

import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.jira.project.UpdateProjectParameters
import org.apache.log4j.Level
import org.apache.log4j.Logger

def projectManager = ComponentAccessor.getProjectManager()
def project = projectManager.getProjectObjByName("Old project name")


if(project) {
def updateProjectParameters = UpdateProjectParameters.forProject(project.id).name("New project name")
projectManager.updateProject(updateProjectParameters)
}
else {
log.debug("Oops, project is unavailable")
}

2 answers

2 accepted

0 votes
Answer accepted
Abhishek Rawat September 3, 2020

Also, based on the code,

I created a single groovy script
that can rename multiple projects by uploading a csv with old and new project names.

Hope this helps anyone who is blocked with the same issue.

 

Cheers!

0 votes
Answer accepted
Ravi Sagar _Sparxsys_
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
August 23, 2020

Hi @Abhishek Rawat 

Let me try to help.

  • Convert your Excel into a csv file and then read the csv file in your script.
  • Iterate over the list of projects. Check this code.
  • Create a method to do the renaming using the code.

Ravi

Abhishek Rawat September 3, 2020

Thanks a lot @Ravi Sagar _Sparxsys_ in fact my initial script is based on your you tube tutorials. Kudos for creating such helpful content.

Suggest an answer

Log in or Sign up to answer