Create
cancel
Showing results for 
Search instead for 
Did you mean: 
Sign up Log in
Celebration

Earn badges and make progress

You're on your way to the next level! Join the Kudos program to earn points and save your progress.

Deleted user Avatar
Deleted user

Level 1: Seed

25 / 150 points

Next: Root

Avatar

1 badge earned

Collect

Participate in fun challenges

Challenges come and go, but your rewards stay with you. Do more to earn more!

Challenges
Coins

Gift kudos to your peers

What goes around comes around! Share the love by gifting kudos to your peers.

Recognition
Ribbon

Rise up in the ranks

Keep earning points to reach the top of the leaderboard. It resets every quarter so you always have a chance!

Leaderboard

Come for the products,
stay for the community

The Atlassian Community can help you and your team get more value out of Atlassian products and practices.

Atlassian Community about banner
4,559,416
Community Members
 
Community Events
184
Community Groups

How to delete versions from Script

Hello,

How to delete versions from Script?

Thanks,

1 answer

0 votes
Nic Brough -Adaptavist-
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
May 15, 2023

Welcome to the Atlassian Community!

What scripting function are you using?

Hello, 

We are using Groovy scripting.

import com.atlassian.jira.component.ComponentAccessor

def projectManager = ComponentAccessor.getProjectManager()
def versionManager = ComponentAccessor.getVersionManager()

def project = projectManager.getProjectObjByKey("INT") //Change project key here for the project you want to change

//100p to create version list

for(int i = 170; 1<=220; i++) { //loop from which to which version you want to update variably
String secondstr = "3.1.28.0" +i; //add the fixed value here which won't change
versionManager.createVersion(secondstr,null,null, "",project.id,null)
}

 

Thanks,

Nic Brough -Adaptavist-
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
May 15, 2023

This is a script which adds versions.  What is the question about deleting them?

Pratish Korathu
I'm New Here
I'm New Here
Those new to the Atlassian Community have posted less than three times. Give them a warm welcome!
May 15, 2023

We are looking for script to bulk delete a series of project version.

Hi @Nic Brough -Adaptavist- 

We have used below script for deleting the Versions, but it is showing Error

import com.atlassian.jira.project.version.Version
import com.atlassian.jira.component.ComponentAccessor

def projectManager = ComponentAccessor.getProjectManager()
def versionManager = ComponentAccessor.getVersionManager()

def project = projectManager.getProjectObjByKey("RPT") //Change project key here for the project you want to change
def versions = versionManager.getVersions(project)
log.warn(versions)
def noOfVersions=versions.size()
log.warn(noOfVersions)
for(def i="3.1.28.068765";i<="3.1.28.068769";i++) {
//String secondstr = "3.1.28.068" +i; //add the fixed value here which won't change
Version versionToDelete=versions[i]
versionManager.deleteVersion(versionToDelete)
}

Thanks,

Nic Brough -Adaptavist-
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
May 17, 2023

What are the errors you are getting?

I'd guess at the line with the loop on it being a problem - your def statement in there is defining i as a string, which you can't iterate over.

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events