Dynamically list Artifact Version in jenkins job parameter

classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

Dynamically list Artifact Version in jenkins job parameter

Vikrant Kaushik
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

--
You received this message because you are subscribed to the Google Groups "Jenkins Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/jenkinsci-users/6d68bfac-73fa-4739-83f4-955c0f73824d%40googlegroups.com.
Reply | Threaded
Open this post in threaded view
|

Re: Dynamically list Artifact Version in jenkins job parameter

Vikrant Kaushik
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)
//return["jsonList.results.name"]
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



On Thursday, 14 November 2019 21:47:00 UTC+5:30, Vikrant Kaushik wrote:
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

--
You received this message because you are subscribed to the Google Groups "Jenkins Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/jenkinsci-users/fd07fcf3-bb6f-4319-affb-c67c3c0a095f%40googlegroups.com.
Reply | Threaded
Open this post in threaded view
|

Re: Dynamically list Artifact Version in jenkins job parameter

Vikrant Kaushik

Capture.JPG

I'm expecting by selecting the choice parameter it will version of the tool:



On Monday, 18 November 2019 14:47:20 UTC+5:30, Vikrant Kaushik wrote:
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", "<a href="https://abc.xyz.local/artifactory/api/search/aql" target="_blank" rel="nofollow" onmousedown="this.href=&#39;https://www.google.com/url?q\x3dhttps%3A%2F%2Fabc.xyz.local%2Fartifactory%2Fapi%2Fsearch%2Faql\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNE1CjQApxuCsG4nok8Mfw5NuCizMw&#39;;return true;" onclick="this.href=&#39;https://www.google.com/url?q\x3dhttps%3A%2F%2Fabc.xyz.local%2Fartifactory%2Fapi%2Fsearch%2Faql\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNE1CjQApxuCsG4nok8Mfw5NuCizMw&#39;;return true;">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)
//return["<a href="http://jsonList.results.name" target="_blank" rel="nofollow" onmousedown="this.href=&#39;http://www.google.com/url?q\x3dhttp%3A%2F%2FjsonList.results.name\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNE0jfEx_ue_WbZ8OTL0oLTQ6NuSWA&#39;;return true;" onclick="this.href=&#39;http://www.google.com/url?q\x3dhttp%3A%2F%2FjsonList.results.name\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNE0jfEx_ue_WbZ8OTL0oLTQ6NuSWA&#39;;return true;">jsonList.results.name"]
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



On Thursday, 14 November 2019 21:47:00 UTC+5:30, Vikrant Kaushik wrote:
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

--
You received this message because you are subscribed to the Google Groups "Jenkins Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/jenkinsci-users/f3a11099-1cb8-47b2-a637-cc1d5bf534d9%40googlegroups.com.