How can I get the project key?

Alexis Evans August 10, 2022

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
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
August 10, 2022

Hi @Alexis Evans 

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

So in reality.
issue.getProjectObject().name
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
Alexis Evans August 10, 2022

Thanks so much, this seemed to work!

Like Craig Nodwell likes this
Craig Nodwell
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
August 10, 2022

Yay
LOL

Suggest an answer

Log in or Sign up to answer