I'd like to create a groovy script to run on the jenkins console to list the job definition with the repository used and the script path (the jenkinsfile), with an output like this:
JobName -> git repository -> script path
So far I was able to list the job name and the git repository, but I can't find a way to get the script path. It doesn't seem contained in the GitSCM plugin, but I can't find a way to obtain it through the WorkflowJob. This is my current code:
Jenkins.instance.getAllItems(Job.class).each{
jobName = it.getName()
if(it instanceof FreeStyleProject){
return
}
scm = it.getTypicalSCM();
if (scm instanceof hudson.plugins.git.GitSCM) {
scm.getRepositories().each{
it.getURIs().each{
println(jobName +"-> "+ it.toString());
}
}
}
}
How can I retrieve the script path?