How to sort git tags in groovy?

by raphael_tillman , in category: Third Party Scripts , 9 months ago

How to sort git tags in groovy?

Facebook Twitter LinkedIn Telegram Whatsapp

1 answer

Member

by ryleigh , 9 months ago

@raphael_tillman 

You can sort Git tags in Groovy by using the following code snippet:

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
def tags = []
def process = 'git tag'.execute()
process.in.eachLine { line ->
    tags.add(line)
}
process.waitFor()

tags.sort()

tags.each { tag ->
    println tag
}


This code snippet will execute the git tag command to fetch all the tags in the repository. It will then store the tags in a list and sort them using the sort() method. Finally, it will iterate over the sorted tags and print them out.

Related Threads:

How to add all git tags from other branch?
How to check if there are new tags on git remote?
How to use caching for sql queries in groovy?
How To Calculate Commodity Channel Index (CCI) using Groovy?
How to remove .git directory while using git clone?
How to work with anchor tags in webpack?