@Override public boolean supports(SCM source) { return source instanceof GitSCM && ((GitSCM) source).getUserRemoteConfigs().size() == 1 && ((GitSCM) source).getBranches().size() == 1 && ((GitSCM) source).getBranches().get(0).getName().matches( "^((\\Q" + Constants.R_HEADS + "\\E.*)|([^/]+)|(\\*/[^/*]+(/[^/*]+)*))$" ); // we only support where the branch spec is obvious }
public List<String> getBranchSpecifier( final Item item ) { List<String> branchSpec = new ArrayList<String>(); SCMTriggerItem s = SCMTriggerItem.SCMTriggerItems.asSCMTriggerItem(item); if(s != null) { for(SCM scm : s.getSCMs()) { if (scm instanceof GitSCM) { GitSCM gitScm = (GitSCM)scm; for(BranchSpec spec : gitScm.getBranches()) { branchSpec.add(spec.getName()); } } } } return branchSpec; }
/** * If the configuration is such that we are tracking just one branch of one repository * return that branch specifier (in the form of something like "origin/master" * <p/> * Otherwise return null. */ private String getSingleBranch(AbstractBuild<?, ?> build) { // if we have multiple branches skip to advanced usecase if (getBranches().size() != 1 || getRepositories().size() != 1) { return null; } String branch = getBranches().get(0).getName(); String repository = getRepositories().get(0).getName(); // replace repository wildcard with repository name if (branch.startsWith("*/")) { branch = repository + branch.substring(1); } // if the branch name contains more wildcards then the simple usecase // does not apply and we need to skip to the advanced usecase if (branch.contains("*")) { return null; } // substitute build parameters if available ParametersAction parameters = build.getAction(ParametersAction.class); if (parameters != null) { branch = parameters.substitute(build, branch); } return branch; }
if (jobSCM instanceof GitSCM) { final GitSCM gitJobSCM = (GitSCM) jobSCM; for (final BranchSpec branchFullName : gitJobSCM.getBranches()) {
private String getSingleBranch(EnvVars env) { if (getBranches().size() != 1) { return null; String branch = getBranches().get(0).getName(); String repository = null;
GitUtils utils = new GitUtils(listener, git); List<Revision> branchRevs = new ArrayList<>(utils.getAllBranchRevisions()); List<BranchSpec> specifiedBranches = gitSCM.getBranches();
if (gitUrl != null && gitUrl.length() > 0) { String ref = null; List<BranchSpec> branches = gitSCM.getBranches(); if (branches != null && branches.size() > 0) { BranchSpec branchSpec = branches.get(0);
public void buildEnvVars(AbstractBuild<?, ?> build, Map<String, String> env) { super.buildEnvVars(build, env); GitUtils.buildBranchEnvVar(build, env, getRepositories(), getBranches()); BuildData bd = fixNull(getBuildData(build, false)); if (bd != null && bd.getLastBuiltRevision() != null) { String commit = bd.getLastBuiltRevision().getSha1String(); if (commit != null) { env.put(GIT_COMMIT, commit); } } }
Branch b = j.next(); boolean keep = false; for (BranchSpec bspec : gitSCM.getBranches()) { if (bspec.matches(b.getName())) { keep = true;
for (BranchSpec branchSpec : getBranches()) { for (Entry<String, ObjectId> entry : heads.entrySet()) { final String head = entry.getKey();
Branch b = j.next(); boolean keep = false; for (BranchSpec bspec : gitSCM.getBranches()) { if (bspec.matches(b.getName())) { keep = true;
@Override public GitSCM createScm(GitHubSCMSource scmSource, SCMHead scmHead, SCMRevision scmRevision) { return new GitSCM( gitSCM.getUserRemoteConfigs(), gitSCM.getBranches(), gitSCM.isDoGenerateSubmoduleConfigurations(), gitSCM.getSubmoduleCfg(), gitSCM.getBrowser(), gitSCM.getGitTool(), gitSCM.getExtensions() ); }
Branch b = j.next(); boolean keep = false; for (BranchSpec bspec : gitSCM.getBranches()) { if (bspec.matches(b.getName(), env)) { keep = true; return Collections.singletonList(utils.sortBranchesForRevision(lastBuiltRevision, gitSCM.getBranches(), env));
for (final BranchSpec branch : git.getBranches()) { final String branchString = branch.toString();
for (URIish remoteURL : repository.getURIs()) { if (GitStatus.looselyMatches(uri, remoteURL)) { for (BranchSpec branchSpec : git.getBranches()) { if (branchSpec.getName().contains("$")) {
branchFound = true; } else { OUT: for (BranchSpec branchSpec : git.getBranches()) { if (branchSpec.getName().contains("$")) {
for (URIish remoteURL : repository.getURIs()) { if (GitStatus.looselyMatches(uri, remoteURL)) { for (BranchSpec branchSpec : git.getBranches()) { if (branchSpec.getName().contains("$")) {
branchMatches = true; } else { for (BranchSpec branchSpec : git.getBranches()) { for (String branch : branches) { if (branchSpec.matches(repository.getName() + "/" + branch)) {
GitSCM gitSCM = (GitSCM) scm; UserRemoteConfig config = gitSCM.getUserRemoteConfigs().get(0); BranchSpec branchSpec = gitSCM.getBranches().get(0); String remote = config.getUrl(); String cacheEntry = AbstractGitSCMSource.getCacheEntry(remote);
final String singleBranch = GitUtils.getSingleBranch(build, getRepositories(), getBranches()); final String paramLocalBranch = getParamLocalBranch(build); Revision tempParentLastBuiltRev = null;