package org.jenkinsci.plugins.p4.scm; import com.perforce.p4java.core.file.IFileSpec; import edu.umd.cs.findbugs.annotations.NonNull; import hudson.Extension; import hudson.model.TaskListener; import org.jenkinsci.Symbol; import org.jenkinsci.plugins.p4.browsers.P4Browser; import org.jenkinsci.plugins.p4.client.ConnectionHelper; import org.kohsuke.stapler.DataBoundConstructor; import org.kohsuke.stapler.DataBoundSetter; import java.nio.file.Path; import java.nio.file.Paths; import java.util.ArrayList; import java.util.Arrays; import java.util.List; import java.util.regex.Pattern; public class BranchesScmSource extends AbstractP4ScmSource { private P4Browser browser; private String filter; @DataBoundConstructor public BranchesScmSource(String id, String credential, String includes, String charset, String format) { super(id, credential); setIncludes(includes); setCharset(charset); setFormat(format); } @DataBoundSetter public void setBrowser(P4Browser browser) { this.browser = browser; } @DataBoundSetter public void setFilter(String filter) { this.filter = filter; } public String getFilter() { return filter; } @Override public P4Browser getBrowser() { return browser; } @Override public List<P4Head> getTags(@NonNull TaskListener listener) throws Exception { return new ArrayList<>(); } @Override public List<P4Head> getHeads(@NonNull TaskListener listener) throws Exception { List<String> paths = getIncludePaths(); List<P4Head> list = new ArrayList<>(); ConnectionHelper p4 = new ConnectionHelper(getOwner(), getCredential(), listener); String actualFilter = getFilter(); if(getFilter() == null || filter.trim().equals("")){ actualFilter = ".*"; } Pattern filterPattern = Pattern.compile(actualFilter); List<IFileSpec> specs = p4.getDirs(paths); for (IFileSpec s : specs) { String branch = s.getOriginalPathString(); // check the filters if(!filterPattern.matcher(branch).matches()){ continue; } // get depotPath and check for null Path depotPath = Paths.get(branch); if (depotPath == null) { continue; } // get filename and check for null Path file = depotPath.getFileName(); if (file == null) { continue; } P4Path p4Path = new P4Path(branch); P4Head head = new P4Head(file.toString(), Arrays.asList(p4Path)); list.add(head); } p4.disconnect(); return list; } @Extension @Symbol("multiBranch") public static final class DescriptorImpl extends P4ScmSourceDescriptor { @Override public String getDisplayName() { return "Helix Branches"; } } }
# | Change | User | Description | Committed | |
---|---|---|---|---|---|
#1 | 23141 | Tsaukpaetra | "Forking branch Main of p4-jenkins to Tsaukpaetra-p4jenkins." | ||
//guest/perforce_software/p4jenkins/main/src/main/java/org/jenkinsci/plugins/p4/scm/BranchesScmSource.java | |||||
#11 | 23028 | Paul Allen |
MultiBranch docs and tidy up. Move getScriptPathOrDefault and getWorkspace from Helix Branches to AbstractP4ScmSource. |
||
#10 | 23024 | Paul Allen |
Merge pull request #59 from fbyrne/JENKINS-45657 [Jenkins-45657] Recreation of pull request |
||
#9 | 23017 | Paul Allen |
MultiBranch configuration cleanup. Remove BETA, hide standard options in Advanced group and added isGraphCompatible check in Populate Descriptor. |
||
#8 | 22875 | Paul Allen | Refactor P4Path and Swarm API | ||
#7 | 22866 | Paul Allen |
Merge pull request #55 from jenkinsci/hth Global Pipeline Library support. JENKINS-46121 JENKINS-46550 |
||
#6 | 22684 | Paul Allen | Added @Symbol to Extension classes for Pipeline Syntax. | ||
#5 | 22678 | Paul Allen |
MultiBranch support for Helix4Git (GitHub PR model). Update MultiBranch product names to Helix. |
||
#4 | 22396 | Paul Allen |
MultiBranch support for Perforce Swarm Reviews. A work in progress - adds Swarm API support to find branches and reviews from a Swarm project. #review-22354 |
||
#3 | 21794 | Paul Allen |
Merge pull request #39 from Dohbedoh/JENKINS-34825 Jenkins 34825 |
||
#2 | 21779 | Paul Allen |
Help for MultiBranch include field and update BETA label. JENKINS-32616 |
||
#1 | 21758 | Paul Allen |
Merge pull request #38 from jenkinsci/dev scm-api 2.0.2 updates |