getPriority

    Signature

    Helper nodeHelper
    Signature getPriority (String priorityName) getPriority (String priorityName, issue)
    Description

    Returns a priority.

     Null if not found

    Returns a priority.

     Null if not found

    Introduced in 0.8 3.2.0

    For Jira Cloud and Jira Server 7.5.x and lower

    Example use

    if (replica.assignee.displayName == "Steve Jobs") {
       issue.priority = nodeHelper.getPriority("Critical")
    } 

    For JIRA Server 7.6 and higher

    In 7.6 version Atlassian introduced priority schemes, which helps to choose different properties for different projects. 

    We retrieve a project key from the issue variable to find a project with a set of priorities.

    Example use

    if (replica.assignee.displayName == "Steve Jobs") {
       issue.priority = nodeHelper.getPriority("Critical", issue)
    } 

    Mapping priorities

    // SETTINGS
    def priorityMapping = [
            "Remote Priority 1": "Local Priority 1"
    ] as Map<String, String>
    // END: SETTINGS
    
    def desiredPriority = priorityMapping[replica.priority.name] ?: replica.priority.name
    issue.priority = nodeHelper.getPriority(desiredPriority, issue)
    if (issue.priority == null) {
        throw new com.exalate.api.exception.IssueTrackerException("""
    Can not find priority `${desiredPriority}` for the project `${issue.project?.key}`.
    Please check project settings or change the script""".toString()
        )
    }