有没有办法通过groovy在Jenkins作业中获取scm git repo url字符串?
答案 0 :(得分:6)
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);
}
}
}
}
答案 1 :(得分:1)
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);
}
}
}}