Jelly Script to delete an Issue

I would like to know the Jelly Tag to delete an issue from a project. I looked at the following link, http://confluence.atlassian.com/display/JIRA044/Jelly+Tags and cannot find the correct Jelly Tag.

2 answers

Jira does not provide a Jelly tag to delete issues. You have to code that the hard way like the example here to delete issue MYPROJECT-6330. Of course some things are still missing here, e.g. checking the validation result and the error collection that is returned by issueService.delete.

<JiraJelly xmlns:jira="jelly:com.atlassian.jira.jelly.enterprise.JiraTagLib" xmlns:core="jelly:core" xmlns:log="jelly:log">


  <!-- Grab managers. Do it using ComponentAccessor now which gives better compatibility in Jira 5! r -->
  <core:invokeStatic className="com.atlassian.jira.component.ComponentAccessor" method="getIssueManager" var="issueManager"/>
  <core:invokeStatic className="com.atlassian.jira.component.ComponentAccessor" method="getIssueService" var="issueService"/>

  <!-- Get users authentication context -->
  <core:invokeStatic className="com.atlassian.jira.component.ComponentAccessor" method="getJiraAuthenticationContext" var="authenticationContext"/>
  <core:invoke on="${authenticationContext}" method="getLoggedInUser" var="user"/>

  <!-- Get the Issue from IssueManager -->
  <core:invoke on="${issueManager}" method="getIssueObject" var="issue">
    <core:arg type="java.lang.String" value="MYPROJECT-6330"/>
  </core:invoke>
  <log:warn>Issue of  ${issue.class} found</log:warn>
  <log:warn>User of ${user.class} found</log:warn>

  <core:invoke on="${issue}" method="getId" var="issueId"/>
  <core:invoke on="${issueService}" method="validateDelete" var="deleteValidationResult">
    <core:arg   value="${user}"/>
    <core:arg  value="${issueId}"/>
  </core:invoke>

  <core:invoke on="${issueService}" method="delete" var="errors">
    <core:arg  value="${user}"/>
    <core:arg  value="${deleteValidationResult}"/>
  </core:invoke>
  <log:warn>deleted</log:warn>


</JiraJelly>

Is there a way to automate this script and execute it against a filter results that include the list of issues to be deleted?

Thanks,

Yaron

The scripts at https://confluence.atlassian.com/display/JIRA/Jelly+Escalation show how you can execute a sewuence of jelly tags against all issues matching a filter. You can also automate jelly scripts using the jelly service
See more at https://confluence.atlassian.com/display/JIRA/Services how to install the Jelly serice. You can get the name of the service implementation class from the source that is linked on this page
If the jelly script does not run in the jelly service and only if it is executed manually in the jelly runner, please make sure you login first as a user that has the right to delete issues. You can login using the jira:login tag as in https://answers.atlassian.com/questions/37551/jira-jelly-service-complains-that-the-workflow-transition-is-not-valid-for-the-current-workflow-state-manual-start-works-fine

Suggest an answer

Log in or Sign up to answer
How to earn badges on the Atlassian Community

How to earn badges on the Atlassian Community

Badges are a great way to show off community activity, whether you’re a newbie or a Champion.

Learn more
Community showcase
Published yesterday in Off-topic

Get to know our Atlassian User Group Leaders from Bengaluru, India

Meet @Dinesh Dhinakaran, @Vishnu Vasudeva, @Rajeev Verma, and Jamshid Nalakath: Our extraordinary AUG leaders from Bengaluru, India. These four work together to strengthen the bonds of their local co...

146 views 0 4
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