Hi,
I am using a groovy script to walk through all jobs, and find the multibranch jobs in a github project. I want to get the full path name to the job, and I'm having problems figuring out what property to pull, even though I can see that the object knows its full path.
Here's what I mean -- Here's a sample of the code:
for (item in Jenkins.instance.items) {
println("Item " + item)
if(item.hasProperty("items")) {
for(item1 in item.items) {
println("Item " + item1)
if(item1.hasProperty("items")) {
for(item2 in item1.items) {
println("Item " + item2)
}
}
}
}
}If I run this, I can see that the jobs found known their full path. This outputs this:
Item jenkins.branch.OrganizationFolder@41f1ea07[MyOrg]
Item org.jenkinsci.plugins.workflow.multibranch.WorkflowMultiBranchProject@6d24ed54[MyOrg/MyProject]
Item org.jenkinsci.plugins.workflow.job.WorkflowJob@5e6f7f42[MyOrg/MyProject/master]
I want to get "MyOrg/MyProject/master" -- obviously the WorkflowJob knows that's what it is.
But if I just look at item2.name, its just "master". No property value seems to be the full path, which is what I need. I can calculate it pretty easy with getParent() calls, but it just feels like its already there, and I'm just not pulling the correct value...
Thanks for the help,
Greg