Dynamically list Artifact Version in jenkins job parameter

18 views
Skip to first unread message

Vikrant Kaushik

unread,
Nov 14, 2019, 11:17:00 AM11/14/19
to Jenkins Users
Hi All,

I'm struggling to get the dynamically list of the Artifact Version in jenkins job parameter, I'm using Jfrog Artifactory as a remote repo.I'm trying with Active choice parameter but don't know how to get version from Artifactory.

Any help would be appreciated. 

regards

Vikrant

Vikrant Kaushik

unread,
Nov 18, 2019, 4:17:20 AM11/18/19
to Jenkins Users
In addition to below, I wrote groovy as below for active choice parameter selection in Jenkins job but this is not working, can someone please help.

import groovy.json.JsonSlurper
try {
def command = ["curl", "-u", "C1111A:Password", "-X", "POST", "-H", "Content-Type: text/plain", "-k", "https://abc.xyz.local/artifactory/api/search/aql", "-d", "items.find({\"path\":\"$env.tools\"})"].execute().text
artifact = new JsonSlurper().parseText(command)
//def jsonList = new JsonSlurper().parseText(command)
List<String> version = new ArrayList<String>()
for (i = 0; i <artifact.results.name.size(); i++) 
{
version.add("'"+artifact['results'][i]['name']+"'")
}
return version
}
catch (Exception e) {
print "Problem fetching the version"
}

regards

Vikrant Kaushik

unread,
Nov 18, 2019, 4:19:55 AM11/18/19
to Jenkins Users

Capture.JPG

I'm expecting by selecting the choice parameter it will version of the tool:
Reply all
Reply to author
Forward
0 new messages