public static List<BranchSpec> createBranches(String[] branch) { List<BranchSpec> branches = new ArrayList<BranchSpec>(); String[] branchData = branch; for (int i = 0; i < branchData.length; i++) { branches.add(new BranchSpec(branchData[i])); } if (branches.size() == 0) { branches.add(new BranchSpec("*/master")); } return branches; }
@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> filterMatching(Collection<String> branches, EnvVars env) { List<String> items = new ArrayList<>(); for(String b : branches) { if(matches(b, env)) items.add(b); } return items; }
newRemoteConfig("origin", source, new RefSpec("+refs/heads/*:refs/remotes/origin/*"))); if (branch != null) { branches.add(new BranchSpec(branch)); } else { branches.add(new BranchSpec("*/master")); String name = branchSpec.getName(); name = name.replace("*", "**"); branchSpec.setName(name);
public boolean matches(String item) { return getPattern().matcher(item).matches(); }
@DataBoundConstructor public BranchSpec(String name) { setName(name); }
/** * @deprecated use {@link #filterMatching(Collection, EnvVars)} * @param branches source branch list to be filtered by configured branch specification using a newly constructed EnvVars * @return branch names which match */ public List<String> filterMatching(Collection<String> branches) { EnvVars env = new EnvVars(); return filterMatching(branches, env); }
newRemoteConfig("origin", source, new RefSpec("+refs/heads/*:refs/remotes/origin/*"),StringUtils.EMPTY)); if (branch != null) { branches.add(new BranchSpec(branch)); } else { branches.add(new BranchSpec(DEFAULT_BRANCH)); String name = branchSpec.getName(); name = name.replace("*", "**"); branchSpec.setName(name);
public boolean matches(String item) { return getPattern().matcher(item).matches(); }
remoteRepositories.add(newRemoteConfig("origin", source, rs.toArray(new RefSpec[rs.size()]))); if (branch != null) { branches.add(new BranchSpec(branch)); } else { branches.add(new BranchSpec("*/master")); String name = branchSpec.getName(); name = name.replace("*", "**"); branchSpec.setName(name);
/** * Creates git branches based. * * @param branchParams parameters. * @return list pf {@link BranchSpec}. */ public static List<BranchSpec> createBranches(String[] branchParams) { List<BranchSpec> branches = new ArrayList<BranchSpec>(); if (ArrayUtils.isEmpty(branchParams)) { branches.add(new BranchSpec(DEFAULT_BRANCH)); } else { for (String branchParam : branchParams) { branches.add(new BranchSpec(branchParam)); } } return branches; }
/** * 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. */ public static String getSingleBranch(AbstractBuild<?, ?> build, List<RemoteConfig> repositories, List<BranchSpec> branches) { // if we have multiple branches skip to advanced usecase if (branches.size() != 1 || repositories.size() != 1) { return null; } String branch = branches.get(0).getName(); String repository = repositories.get(0).getName(); return buildBranch(build, repository, branch); }
} else { OUT: for (BranchSpec branchSpec : git.getBranches()) { if (branchSpec.getName().contains("$")) { } else { for (String branch : branches) { if (branchSpec.matches(repository.getName() + "/" + branch)) { if (LOGGER.isLoggable(Level.FINE)) { LOGGER.fine("Branch Spec " + branchSpec + " matches modified branch " + branch + " for " + project.getFullDisplayName() + ". ");
public List<String> filterMatching(Collection<String> branches) { List<String> items = new ArrayList<String>(); for (String b : branches) { if (matches(b)) { items.add(b); } } return items; }
/** * Compare a git branch reference to configured pattern. * <p> * reference uses normalized format `ref/(heads|tags)/xx` * pattern do support * <ul> * <li>ref/heads/branch</li> * <li>(remote-name)?/branch</li> * <li>ref/remotes/branch</li> * <li>tag</li> * <li>(commit sha1)</li> * </ul> * @param ref branch reference to compare * @param env environment variables to use in comparison * @return true if ref matches configured pattern */ public boolean matches(String ref, EnvVars env) { return getPattern(env).matcher(ref).matches(); }
@Nonnull List<BranchSpec> getBranchSpecs() { return singletonList(new BranchSpec(getRef())); }
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; }
public List<String> filterMatching(Collection<String> branches) { List<String> items = new ArrayList<String>(); for (String b : branches) { if (matches(b)) { items.add(b); } } return items; }