Come for the products,
stay for the community

The Atlassian Community can help you and your team get more value out of Atlassian products and practices.

Atlassian Community about banner
Community Members
Community Events
Community Groups

How can I get the project key?

I am using Groovy in Scriptrunner. I've imported com.atlassian.jira.project.Project and I need to get the project key of the current project in a validator script. What would be the correct way to do this?

1 answer

1 accepted

0 votes
Answer accepted
Craig Nodwell Community Leader Aug 10, 2022

Hi @Alexis Evans 

def issueproject = issue.getProjectObject().name 
return issueproject 
this will return the project name for the issue.

So in reality.
I'm not even sure if you need to import com.atlassian.jira.project.Project or if all you need is
import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.jira.issue.IssueManager
import com.atlassian.jira.issue.Issue

I pulled the value out of my console without the project.Project call

Thanks so much, this seemed to work!

Like Craig Nodwell likes this
Craig Nodwell Community Leader Aug 10, 2022


Suggest an answer

Log in or Sign up to answer