Just a heads up: On March 24, 2025, starting at 4:30pm CDT / 19:30 UTC, the site will be undergoing scheduled maintenance for a few hours. During this time, the site might be unavailable for a short while. Thanks for your patience.

×
Create
cancel
Showing results for 
Search instead for 
Did you mean: 
Sign up Log in

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
atlassian, atlassian government cloud, fedramp, webinar, register for webinar, atlassian cloud webinar, fedramp moderate offering, work faster with cloud

Unlocking the future with Atlassian Government Cloud ☁️

Atlassian Government Cloud has achieved FedRAMP Authorization at the Moderate level! Join our webinar to learn how you can accelerate mission success and move work forward faster in cloud, all while ensuring your critical data is secure.

Register Now
AUG Leaders

Upcoming Apps & Integrations Events