jenkins_api_client icon indicating copy to clipboard operation
jenkins_api_client copied to clipboard

list matching jobs using dsl

Open sahal opened this issue 8 years ago • 9 comments

Incorporates jhoblitt's groovy script to get a full list of folders. See #210

sahal avatar Feb 24 '17 15:02 sahal

Hi @sahal ! I fixed the tests and added a new one to ensure we don't get false positives from folder names.

dayer4b avatar Apr 04 '17 21:04 dayer4b

Is this ready to merge? I would love to get it added the to lita-jenkins-client gem

nicgrayson avatar May 06 '17 03:05 nicgrayson

@tmiller it looks like we need more tests if this is breaking something! I'll take another look soon

dayer4b avatar May 23 '17 19:05 dayer4b

@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?

dayer4b avatar Jul 11 '17 17:07 dayer4b

@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.parsed 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!

katelovescode avatar Nov 27 '17 03:11 katelovescode

@sahal @dayer4b - this PR might help: https://github.com/arangamani/jenkins_api_client/pull/237

katelovescode avatar Nov 27 '17 04:11 katelovescode

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

katelovescode avatar Nov 27 '17 04:11 katelovescode

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.

snowe2010 avatar Oct 02 '19 21:10 snowe2010

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.

arangamani avatar Oct 04 '19 23:10 arangamani

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.

snowe2010 avatar Oct 05 '19 19:10 snowe2010