jenkins_api_client
jenkins_api_client copied to clipboard
list matching jobs using dsl
Incorporates jhoblitt's groovy script to get a full list of folders. See #210
Hi @sahal ! I fixed the tests and added a new one to ensure we don't get false positives from folder names.
Is this ready to merge? I would love to get it added the to lita-jenkins-client gem
@tmiller it looks like we need more tests if this is breaking something! I'll take another look soon
@tmiller, I'm sorry, but I can't tell by your comments if this is breaking something for you or needs to be fixed. Can you be more specific about what functionality is broken?
@sahal @dayer4b - take a look at the change I made to the list
method; the output of the Groovy script is not a hash with a jobs
key, but an array of job hashes, which needs to be JSON.parse
d to loop through it. Also calling the keys by symbol wasn't working, so I swapped it to strings. There's more work that needs to be done on this; many of the list_
methods rely on this and the nesting isn't working for all of them. list_all
still only lists top-level jobs and top-level folders.
I was testing this locally with an instance of Jenkins running, the login_with_irb
script, and @client.job.list("job_name")
. I have CloudBees folders installed locally and I created jobs at the top level and one folder deep, but didn't get further than that.
With a search for a job named geordi
, with one job named geordi
at root, and one job named geordi
inside a picard
folder, the output of puts response_json
at line 706 of job.rb
is the following:
[{"_class":"hudson.model.FreeStyleProject","name":"geordi","url":"http://0.0.0.0:8080/job/geordi/"},{"_class":"hudson.model.FreeStyleProject","name":"kate","url":"http://0.0.0.0:8080/job/kate/"},{"_class":"com.cloudbees.hudson.plugins.folder.Folder","name":"picard","url":"http://0.0.0.0:8080/job/picard/"},{"_class":"hudson.model.FreeStyleProject","name":"picard/geordi","url":"http://0.0.0.0:8080/job/picard/job/geordi/"},{"_class":"hudson.model.FreeStyleProject","name":"picard/riker","url":"http://0.0.0.0:8080/job/picard/job/riker/"},{"_class":"hudson.model.FreeStyleProject","name":"whatever","url":"http://0.0.0.0:8080/job/whatever/"}]
Hope that helps!
@sahal @dayer4b - this PR might help: https://github.com/arangamani/jenkins_api_client/pull/237
https://github.com/arangamani/jenkins_api_client/pull/256 <-- my changes are in this PR. I'm still getting used to Github over Stash/Bitbucket
Hi, what is the status of this pr? Is anyone working it? We're looking at using this gem, but it's completely useless to us without this PR. Not a single job is outside of a folder for us.
Hi @snowe2010, According to @katelovescode's comment above, this needs more work and I don't believe anybody is actively working on it. Feel free to take a stab at it if you're interested.
I'll pass it along to the team to let them know. Not sure if one of us will have time to take it though.