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

This widget could not be displayed.

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
Atlassian Summit 2018

Meet the community IRL

Atlassian Summit is an excellent opportunity for in-person support, training, and networking.

Learn more
Community showcase
Posted 3 hours ago in Statuspage

What are your best incident management tips and stories? #HugOps

 👋Community members! Downtime happens. And great incident response takes a village. Teams like Support, Dev, SRE, Ops, IT, and Marketing have to come together to resolve the problem while keep...

19 views 0 2
Join discussion

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