Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

This page explains how to access the value of Standard JIRA Jira fields using Groovy. You can access them using getters of the Issue interface. To understand how to write values into the writable Standard JIRA Jira fields see Raw value/text input for fields and Groovy expression input for fields.

...

Panel
borderStylesolid

Labels

  • Field name: Labels

  • Field ID: labels

  • Description: Labels is a Set of labels.

  • Accessing the Labels field: You can access the Labels field using any of the following getters of the Issue interface:
    • get("labels") or get("Labels") that returns a Set<Label>
      • Example: Get the first label of the issue:

        Code Block
        languagegroovy
        linenumberstrue
        if (issue.get("labels"))
        {
        
          issue.get("labels").first()
        }.label


    • getAsString("Labels") or getAsString("labels") that returns a String with comma separated label names:

      • Examples: Labels of the issue

        Code Block
        languagegroovy
        linenumberstrue
        issue.getAsString("labels")


    • getLabels() that returns a Set<Label>

      • Example: Get the last label of the issue

        Code Block
        languagegroovy
        linenumberstrue
        if(issue.getLabels())
        {   issue.getLabels().last()
        }.label


      • Example: All the labels of the issue separated by a comma:

        Code Block
        languagegroovy
        linenumberstrue
        issue.getLabels().join(",")


...