Right now, I'm parsing the config.xml to get this information, but I'm
wondering if there is a cleaner way of getting this information.
Thanks!
--
View this message in context: http://jenkins.361315.n4.nabble.com/Get-list-of-Jobs-in-a-View-tp3615221p3615221.html
Sent from the Jenkins users mailing list archive at Nabble.com.
You can request http://<your server>/view/<view name>/api/xml to get the
list of jobs.
-- Dean
[1] https://wiki.jenkins-ci.org/display/JENKINS/Remote+access+API
well, it all depends what you understand as 'programmatically' ;O).
Here are some recipes:
1.) Get the list from an external shell command
Get URL http://<SERVER>/view/<VIEW>/api/xml as Dean Yu suggested and
process the XML response in your shell script. Note: You can also get
the same information in JSON via http://<SERVER>/view/<VIEW>/api/json.
2.) Get the list via Jenkins Command Line Interface (CLI)
Run the following CLI command that in turn executes a Groovy script on
the Jenkins master (enter the commmand in one single line):
java -jar jenkins-cli.jar -s http://<SERVER> groovysh
"hudson.model.Hudson.instance.getView('<VIEW>').items.each() { println
it.fullDisplayName }"
3.) Get the list via Groovy from within Jenkins
Run the following snippet in the Scripting console or a Groovy build
step (the latter requires the installation of the Groovy plugin):
hudson.model.Hudson.instance.getView('<VIEW>').items.each() { println
it.fullDisplayName }
4.) Get the list via Java from within a plugin
for(TopLevelItem project :
hudson.model.Hudson.getInstance().getView("<VIEW>").getItems() {
String projectName = project.getFullDisplayName();
[... do something here ...]
}
Cheers,
Simon.
--
grayaii (21.06.2011 22:25):
--
View this message in context: http://jenkins.361315.n4.nabble.com/Get-list-of-Jobs-in-a-View-tp3615221p3990108.html
Hi!
Thanks,
-Chris