Is there a way to get the scm git repo url string inside a Jenkins job with groovy?
import jenkins.model.*;
import hudson.model.*;
import hudson.tasks.*;
import hudson.plugins.git.*;
import org.eclipse.jgit.transport.RemoteConfig;
import org.eclipse.jgit.transport.URIish;
for(project in Hudson.instance.items) {
scm = project.scm;
if (scm instanceof hudson.plugins.git.GitSCM) {
for (RemoteConfig cfg : scm.getRepositories()) {
for (URIish uri : cfg.getURIs()) {
println("SCM " + uri.toString() + " for project " + project);
}
}
}
}
Jenkins.instance.getAllItems(Job.class).each{
scm = it.scm;
project = it;
if (scm instanceof hudson.plugins.git.GitSCM) {
scm.getRepositories().each{
it.getURIs().each{
println("SCM " + it.toString() + " in " + project);
}
}
}}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With