Hi!
I am trying to get these scripts to work (#3 or #4). The problem is that
I have "folders" between my views. And since I don't know what the
expected output is, or where the hudson function starts, I can't get any
output other than "null" as a response.
I have a "project" folder, then a "Builds" folder, then a version folder.
Under the version folder are the Views. I have two.
Using the folder method, the path is /Project/Builds/Version.
And on the URL it shows up as .../Project/job/Builds/job/Version
When I am in the URL and in the View, it shows up as:
.../Project/job/Builds/job/Version/view/ViewName
None of this has helped me figure out what the "getView" or other functions
return.
I am trying to make a groovy script to turn off (or on) jobs by view. I
have the one with the folders working. But the views give me more
granularity in to the pieces of our builds.
Can someone point me to the place where the expected output is described?
Thanks,
-Chris
On Wednesday, June 22, 2011 at 7:30:56 AM UTC-5, Simon Wiest wrote:
>
> Hi grayaii,
>
> 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):
> > Is it possible to get a list of jobs that are in a particular "View"
> > programmatically?
> >
> > 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!
>
>
--
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 [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/jenkinsci-users/f1c25412-ab46-4340-b119-2394a3f88437%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.