List artifacts from artifactory repo to choice parameter dynamically

I have a repository in Artifactory and it has .zip files

I would like to setup a choice parameterized build where the choices dropdown should have the list of Artifacts from Artifactory repo

I have installed "Active Choice parameter" plugin and written Groovy script using REST api.


Groovy script works fine on my local machine but it does not populate anything when i use in Jenkins - Not sure what the issue is. 

Adding sample script below. Please help out on this. 


import groovy.json.JsonSlurper
def List<String> artifacts = new ArrayList<String>()
def response = ["curl", "-X", "POST", "-H", "Content-Type: text/plain", "-k", "-u", "uname:Password", "https://artifactory.com/artifactory/api/search/aql", "-d", "'items.find({\"repo\":\"reponame-local\"})'"].execute().text
def acList=[]
def list = artifacts
data = new JsonSlurper().parseText(response)
for (i = 0; i < data.results.name.size(); i++) {
List modifiedList = list.collect{ "'" + it + "'"}
acList.add(it as String)
return acList





Please sign in to leave a comment.