Jira Jelly how do I add label to an issue?

justin.taylor@ooba.co.za June 4, 2013

Hi

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>

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

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

</core:invoke>

Any help would be very much appreciated, thank you!

1 answer

1 accepted

3 votes
Answer accepted
David Pinn
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
June 4, 2013

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;/jira:CreateProject&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&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:invokeStatic&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;
    &lt;/core:invoke&gt;
&lt;/JiraJelly&gt;

justin.taylor@ooba.co.za June 4, 2013

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

Stefan Niedermann April 2, 2014

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

Suggest an answer

Log in or Sign up to answer