This article is to help build a solution with Jira Automation to delete versions with the same name on different projects.
For instance, when the version test23 is deleted on the HR project, we want to delete the version with the same name on the Support project.
Implementation:
Currently, in Automation, we don’t have an action to delete a version; therefore, we need to use the REST API endpoint for this task.
High-level overview of the rule:
When a version is deleted on the HR project.
Save the deleted version name.
Find the version ID of the version with the same name under the Support project.
Delete the version using the REST API endpoint.
Rule implementation:
Use the version deleted trigger.
Save the deleted version name in a variable called varversion.
Use the send web request to query the versions on the Support project with the same name.
Web Request URL:
GET <CLOUD URL>/rest/api/3/project/DMS/version?query={{varversion}}
Save the web response in a smart value:
{{webResponse.body}}
Using the response body, you can read the version id. In my case, the id is:
{{webResponse.body.values.id}}
Save the version id into a variable called varid
Use the Delete and replace version API endpoint to use delete the version on the Support project.
Web Request URL:
POST https://halaelroumy.atlassian.net/rest/api/3/version/{{varid}}/removeAndSwap{
"customFieldReplacementList": [
{
"customFieldId": 10295,
"moveTo": 10295
}
],
"moveAffectedIssuesTo": 10295,
"moveFixIssuesTo": 10295
}
When you delete a version, you need to choose another version to move any work items associated with the deleted version. In my case, I chose version id 10295.
Let’s look at how the rule would look like:
The Audit log:
If the version name contains spaces, you might need to enclose the smart value holding the version name using the urlEncode function.
In the GET API call, the Web Request URL will be:
GET <CLOUD URL>/rest/api/3/project/<Project Key>/version?query={{version.name.urlEncode}}
Other Automation Articles:Jira Automation: Updating a Confluence page with information from Jira issues
Jira Automation: Linking a Confluence page with Jira issues
Thank you for reading, and Happy Automation!
Hala ElRoumy
Jira Cloud Support Engineer
Atlassian
Amsterdam
4 accepted answers
Online forums and learning are now in one easy-to-use experience.
By continuing, you accept the updated Community Terms of Use and acknowledge the Privacy Policy. Your public name, photo, and achievements may be publicly visible and available in search engines.
0 comments