Forums

Articles
Create
cancel
Showing results for 
Search instead for 
Did you mean: 

Change name of project with post function

Darko Jolic May 25, 2018

Hello,

do you have any suggestion how we can change name of project (only name, not key) automatically with post function? Can we do that with script runner?

 

Thanks,
Darko

2 answers

1 accepted

0 votes
Answer accepted
Thanos Batagiannis [Adaptavist]
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.
May 25, 2018

With Script Runner you could create a custom script post function with the following script 

import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.jira.issue.MutableIssue
import com.atlassian.jira.project.Project
import com.atlassian.jira.project.UpdateProjectParameters

def issue = issue as MutableIssue

final def NEW_PROJECT_NAME = "New Project Name"

def project = issue.projectObject
if (project.name == NEW_PROJECT_NAME) {
log.debug "Project name is already updated - do nothing"
return
}

changeProjectName(project, NEW_PROJECT_NAME)

Project changeProjectName(Project project, String newname) {
def updateProjectParameters = UpdateProjectParameters.forProject(project.id).name(newname)

ComponentAccessor.projectManager.updateProject(updateProjectParameters)
log.debug "Project $project.key name updated"
}
Darko Jolic May 28, 2018

That is exactly what I need.
Thank you for answer Thanos!

Salim Hammar
Contributor
February 11, 2022

Hi @Thanos Batagiannis [Adaptavist] 

 

I find a script listenner for update a component , when i change name the component the name changed in an other project with project key ?

 

Thanks in advance !

0 votes
Mirek
Community Champion
May 25, 2018

Probably by using REST API. You can try webhooks to send a request.

https://developer.atlassian.com/server/jira/platform/webhooks/

Darko Jolic May 28, 2018

I will first try to solve problem with script runner. Thank you for suggestion.

Suggest an answer

Log in or Sign up to answer