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.jenkinsci.plugins.p4.client.ViewMapHelper; import org.jenkinsci.plugins.p4.workspace.ManualWorkspaceImpl; import org.jenkinsci.plugins.p4.workspace.Workspace; import org.jenkinsci.plugins.p4.workspace.WorkspaceSpec; import org.kohsuke.stapler.DataBoundConstructor; import org.kohsuke.stapler.DataBoundSetter; import java.util.ArrayList; import java.util.List; import java.util.regex.Pattern; public class BranchesScmSource extends AbstractP4ScmSource { private P4Browser browser; private String filter = DescriptorImpl.defaultFilter; private String mappings = DescriptorImpl.defaultPath; @DataBoundConstructor public BranchesScmSource(String credential, String includes, String charset, String format) { super(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; } public String getMappings() { // support 1.8.1 configurations that did not have any mappings if (mappings == null) { mappings = DescriptorImpl.defaultPath; } return mappings; } @DataBoundSetter public void setMappings(String mappings) { this.mappings = mappings; } @Override public P4Browser getBrowser() { return browser; } @Override public List<P4SCMHead> getTags(@NonNull TaskListener listener) throws Exception { return new ArrayList<>(); } @Override public List<P4SCMHead> getHeads(@NonNull TaskListener listener) throws Exception { List<String> paths = getIncludePaths(); List<P4SCMHead> list = new ArrayList<>(); try (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 branch is not empty if (branch == null || branch.isEmpty()) { continue; } // check the filters if (!filterPattern.matcher(branch).matches()) { continue; } // get filename and check for null String file = branch.substring(branch.lastIndexOf("/") + 1); if (file == null || file.isEmpty()) { continue; } P4Path p4Path = new P4Path(branch); P4SCMHead head = new P4SCMHead(file, p4Path); list.add(head); } } return list; } @Override public Workspace getWorkspace(P4Path path) { if (path == null) { throw new IllegalArgumentException("missing branch path"); } List<String> views = new ArrayList<>(); for (String mapping : getViewMappings()) { StringBuffer sb = new StringBuffer(); sb.append(path.getPath()); sb.append("/"); sb.append(mapping); views.add(sb.toString()); } String client = getFormat(); String jenkinsPath = path.getPath() + "/" + getScriptPathOrDefault(); String jenkinsView = ViewMapHelper.getClientView(jenkinsPath, client); String mappingsView = ViewMapHelper.getClientView(views, client); String view = jenkinsView + "\n" + mappingsView; WorkspaceSpec spec = new WorkspaceSpec(view, null); return new ManualWorkspaceImpl(getCharset(), false, client, spec); } private List<String> getViewMappings() { return toLines(getMappings()); } @Extension @Symbol("multiBranch") public static final class DescriptorImpl extends P4SCMSourceDescriptor { public static final String defaultPath = "..."; public static final String defaultFilter = ".*"; @Override public String getDisplayName() { return "Helix Branches"; } } }
# | Change | User | Description | Committed | |
---|---|---|---|---|---|
#29 | 28015 | Paul Allen |
MultiBranch exclude filter. A regular expression exclude filter for Swarm branches, Stream names and Branch paths. JENKINS-58346 JENKINS-63625 |
||
#28 | 25564 | Paul Allen |
Merge branch 'local_map' MultiBranch support for 'HelixBranches' local and remote Mappings. Allows MultiBranches to map Depot paths external to the MultiBranch projects root. For example, a MultiBranch project with the following Jenkinsfiles: ProjA >> main //depot/projA/main/Jenkinsfile //depot/projA/main/src/... ProjA>> dev //depot/projA/dev/Jenkinsfile //depot/projA/dev/src/... An 'Includes' path for Branch Sources set to: //depot/projA/... Jenkins will now create two branches 'main' and 'dev'. The default Mapping is '...' so the 'src/...' and any other files under the branch root will appear in the project's workspace. To import an extenal location we can add another line to the mapping: ... //depot/external/stuff/... Now both branches 'main' and 'dev' will have a folder 'depot/external/stuff' with the mapped files. We can also use the `BRANCH_NAME` environment variable in the remote path uses the branch name. ... //depot/external/${BRANCH_NAME}/... and in 'main' you will now see the remote files in ' depot/external/main' along with the local project files mapped with '...' |
||
#27 | 25014 | Paul Allen |
Scan per change support for MultiBranch with remote Jenkinsfiles. Only the 'Polling per Change' Filter is supported; need to disable or support the other filter types. JENKINS-53936 |
||
#26 | 25006 | Paul Allen |
Support for remote Jenkinsfiles in a MultiBranch project. Jenkinsfile are idenitified by the Include branches path (e.g. //depot/Remote/...), but you must add a Mapping in the BranchSource->Advanced->View Mappings to locate the projects source and use a special ${BRANCH_NAME} in the path. e.g. //depot/ProjectA/${BRANCH_NAME}/... JENKINS-53936 |
||
#25 | 24829 | Paul Allen |
Support Jenkinsfiles in sub directories. Preserve Jenkinsfile path in Client View. JENKINS-54382 |
||
#24 | 24670 | Paul Allen |
Swarm review support for MultiBranch scanning. Changed TempClient view map to add Jenkinsfile at the bottom. |
||
#23 | 24662 | Paul Allen |
Undo *SCMSource rename to original *ScmSource. Reslove configuration loading issue due to 1.9.0 bad release. |
||
#22 | 24504 | Paul Allen |
Tree walter for BranchSCMSource Events. On a change-submit event use the change number and grab a submitted file. Walk up the path looking for a Jenkinsfile, then derive 'Project' path, 'Branch' name and 'Path' for the SCMHead/Revision. This assumes that the Jenkinsfile is in the route of your projects. Alternatively use the Swarm Event and pass your own 'Project', 'Branch' and 'Path'. |
||
#21 | 24501 | Paul Allen | Refactor to use P4SCMXxx naming convention. | ||
#20 | 24492 | Paul Allen |
Initial work for MultiBranch Event trigger. JENKINS-52066 (Triggered Events and not Polling per change) |
||
#19 | 24487 | Paul Allen | Perforce Connection Refactor. | ||
#18 | 24454 | Paul Allen |
Exclude and Include mapping support. Refactored P4Path usage and added P4SwarmPath. JENKINS-49804 |
||
#17 | 24439 | Paul Allen |
Move ViewMapHelper to shared class. JENKINS-52852 |
||
#16 | 24233 | Paul Allen |
Merge pull request #74 from msmeeth56/master Updated tests to work against Windows, and lower spec computers. JENKINS-52145 |
||
#15 | 23373 | Paul Allen |
Lightweight checkout support. Implementation for scm-api classes SCMFile and SCMFileSystem, allowing Jenkins to navigate Perforce within the scope of a workspace view. Lightweight checkout uses a tempoary Perforce workspace to naviagete and fetch the files. The client name and client view mapping will be modified from a template name e.g. jenkins-${NODE_NAME}-${JOB_NAME} to the tempoary name jenkinsTemp-UUID. Alternativly if a user as used ${P4_CLIENT} in the client mapping this will remain unchanged and will be get expanded during the job run. JENKINS-45999 JENKINS-46269 |
||
#14 | 23320 | Paul Allen | Remove deprecated ID for SCMSource constructor. | ||
#13 | 23261 | Paul Allen | Backwards compatibility for new Mappings field in MultiBranch. | ||
#12 | 23217 | Paul Allen |
Add the ability to provide a view spec to Helix Branches SCM Pr/61. Review Pr/64 |
||
#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 |
||
//guest/perforce_software/p4jenkins/main/src/main/java/org/jenkinsci/plugins/p4/scm/BranchesSCMSource.java | |||||
#1 | 24504 | Paul Allen |
Tree walter for BranchSCMSource Events. On a change-submit event use the change number and grab a submitted file. Walk up the path looking for a Jenkinsfile, then derive 'Project' path, 'Branch' name and 'Path' for the SCMHead/Revision. This assumes that the Jenkinsfile is in the route of your projects. Alternatively use the Swarm Event and pass your own 'Project', 'Branch' and 'Path'. |
||
# | Change | User | Description | Committed | |
#21 | 24501 | Paul Allen | Refactor to use P4SCMXxx naming convention. | ||
#20 | 24492 | Paul Allen |
Initial work for MultiBranch Event trigger. JENKINS-52066 (Triggered Events and not Polling per change) |
||
#19 | 24487 | Paul Allen | Perforce Connection Refactor. | ||
#18 | 24454 | Paul Allen |
Exclude and Include mapping support. Refactored P4Path usage and added P4SwarmPath. JENKINS-49804 |
||
#17 | 24439 | Paul Allen |
Move ViewMapHelper to shared class. JENKINS-52852 |
||
#16 | 24233 | Paul Allen |
Merge pull request #74 from msmeeth56/master Updated tests to work against Windows, and lower spec computers. JENKINS-52145 |
||
#15 | 23373 | Paul Allen |
Lightweight checkout support. Implementation for scm-api classes SCMFile and SCMFileSystem, allowing Jenkins to navigate Perforce within the scope of a workspace view. Lightweight checkout uses a tempoary Perforce workspace to naviagete and fetch the files. The client name and client view mapping will be modified from a template name e.g. jenkins-${NODE_NAME}-${JOB_NAME} to the tempoary name jenkinsTemp-UUID. Alternativly if a user as used ${P4_CLIENT} in the client mapping this will remain unchanged and will be get expanded during the job run. JENKINS-45999 JENKINS-46269 |
||
#14 | 23320 | Paul Allen | Remove deprecated ID for SCMSource constructor. | ||
#13 | 23261 | Paul Allen | Backwards compatibility for new Mappings field in MultiBranch. | ||
#12 | 23217 | Paul Allen |
Add the ability to provide a view spec to Helix Branches SCM Pr/61. Review Pr/64 |
||
#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 |