Jira Jelly how do I add label to an issue?


I am needing to set a label on an issue in my jelly script, I know how to get the labels, but I cant find anything in the javadocs that allows me to create a new label or get an existing label to set on an issue:

<core:invoke on="${issueKey}" method="getLabels" var="labels" />

<!-- Get or create a label -->

<core:invoke on="${labels}" method="add" var="flag">

<core:arg type="com.atlassian.jira.issue.label.Label" value="???" />


<core:invoke on="${issueKey}" method="setLabels">

<core:arg type="java.util.Collection" value="${labels}" />


Any help would be very much appreciated, thank you!

1 answer

1 accepted

You can use the LabelManager, like this:

&lt;?xml version="1.0" encoding="utf-8" standalone="yes"?&gt;
&lt;JiraJelly xmlns:jira="jelly:com.atlassian.jira.jelly.JiraTagLib" xmlns:core="jelly:core" xmlns:log="jelly:log"&gt;

    &lt;jira:CreateProject key="XYZ" name="XYZ Project" lead="admin"&gt;
        &lt;jira:CreateIssue summary="Rocket thrusters not firing" reporter="admin" assignee="admin" issueIdVar="issueId" /&gt;

    &lt;core:invokeStatic className="java.lang.Class" method="forName" var="clazz"&gt;
        &lt;core:arg type="java.lang.String" value="com.atlassian.jira.issue.label.LabelManager" /&gt;

    &lt;core:invokeStatic className="com.atlassian.jira.component.ComponentAccessor" 
                       method="getComponent" var="labelManager"&gt;
      &lt;core:arg type="java.lang.Class" value="${clazz}" /&gt;

    &lt;core:invoke on="${labelManager}" method="addLabel"&gt;
     &lt;core:arg type="com.atlassian.crowd.embedded.api.User" value="${jelly.user}" /&gt;
     &lt;core:arg type="java.lang.Long" value="${issueId}" /&gt;
     &lt;core:arg type="java.lang.String" value="oops" /&gt;
     &lt;core:arg type="boolean" value="false" /&gt;

Awesome, once again you are a master, thanks David.

Is this possible without updating the updatedDate, too? e.g. the comment manager has a flag "tweakIssueUpdateDate".

Suggest an answer

Log in or Join to answer
Community showcase
Alexey Matveev
Published Saturday in Jira

How to run Jira in a docker container

Everything below is tested on Ubuntu 17.10. I prefer to use Jira in a docker container because: 1. I can install Jira with a couple of commands. 2. I can start and stop Jira just by starting and s...

95 views 2 5
Read article

Atlassian User Groups

Connect with like-minded Atlassian users at free events near you!

Find a group

Connect with like-minded Atlassian users at free events near you!

Find my local user group

Unfortunately there are no AUG chapters near you at the moment.

Start an AUG

You're one step closer to meeting fellow Atlassian users at your local meet up. Learn more about AUGs

Groups near you
Atlassian Team Tour

Join us on the Team Tour

We're bringing product updates and pro tips on teamwork to ten cities around the world.

Save your spot