Jelly Script to delete an Issue

Deleted user March 30, 2012

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

0 votes
Dieter
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.
March 30, 2012

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>

Yaron Gur-Ari October 9, 2012

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

Dieter
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.
October 10, 2012
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
Dieter
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.
October 10, 2012
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
Dieter
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.
October 10, 2012
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
0 votes
Ramiro Pointis
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.
March 30, 2012

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events