Jira Jelly how do I add label to an issue?

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
Accepted answer

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;

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 Sign up to answer
Community showcase
Published 7 hours ago in Agile

How Scrum works? It starts with training and education

To answer “How scrum works,” most of the teams I've worked with first addressed the question: “where to start?”  That question applies to both implementation and improvements on the Scrum framew...

74 views 2 3
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