Jira Scriptrunner get ProjectKey when project ist created

ITSO AS March 19, 2019

Hi

I want to execute a script whenever a new project is created. I implemented this with a Listener in Scriptrunner with the ProjectCreatedEvent. The script gets executed correctly, but now we'd like to pass the ProjectKey and ProjectName as Parameter in the script.

Does anyone know how to get the ProjectKey and ProjectName of the newly created Project?

I only found a few commands where an issue is needed to get the ProjectKey, but since the project is newly created, I got no Issue...

Thanks for your help.

 

2 answers

1 accepted

1 vote
Answer accepted
Rafael Pinto Sperafico
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.
March 19, 2019

Hi @ITSO AS ,

From ProjectCreatedEvent you can get Project

import com.atlassian.jira.project.Project
import org.apache.log4j.Category

def Category log = Category.getInstance("com.onresolve.jira.groovy")
log.setLevel(org.apache.log4j.Level.DEBUG)
log.debug("debug statements")

def project = event.project as Project
log.debug(project.getKey())
log.debug(project.getName())

Kind regards,
Rafael 

ITSO AS March 19, 2019

It worked, Thank you very much!

Kind regards,
Benjamin

0 votes
Mark Markov
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.
March 19, 2019

Hello @ITSO AS 

ProjectCreatedEvent have method getProject(), that will return Project object, so you can get name and key like this

 

def projectName = event.getProject().getName()
def projectKey = event.getProject().getKey()

See https://docs.atlassian.com/software/jira/docs/api/7.1.8/com/atlassian/jira/event/ProjectCreatedEvent.html

parthiban_selvaraj January 13, 2020

Hi @Mark Markov ,

 

Do we any method to get creator of New Project in script Listeners?

eg:

def projectName = event.getProject().getCreator() 

 Thanks,

Parthiban

CC @Thanos Batagiannis [Adaptavist] , @Nic Brough -Adaptavist- 

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events