This gist I want to shere how to get data from bitbucket api.
In my case, I want to list all repo tag
curl -v https://user:[email protected]/2.0/repositories/reposname/project-name/refs/tags
find Authorization key
> Host: api.bitbucket.org
> Authorization: Basic #TOKEN
> User-Agent: curl/7.54.0
> Accept: */*
curl -H "Authorization: Basic #TOKEN" https://api.bitbucket.org/2.0/repositories/reposname/project-name/refs/tags
import groovy.json.JsonSlurper
def name = "reponame"
def git_path = "https://api.bitbucket.org/2.0/repositories/reposname/${name}/refs/tags"
def get = new URL(git_path)
.openConnection();
get.addRequestProperty("Authorization", "Basic #TOKEN");
def responseCode = get.getResponseCode();
def content = get.getInputStream().getText();
def contentList = new JsonSlurper().parseText(content);
println(responseCode)
def jsondata = [tags:contentList.values.sort { it.date }]
jsondata.tags.each {
println(it.name)
}