package org.jenkinsci.plugins.p4.scm; import edu.umd.cs.findbugs.annotations.NonNull; import hudson.Extension; import hudson.model.TaskListener; import jenkins.scm.api.SCMHead; import jenkins.scm.api.SCMRevision; import org.jenkinsci.Symbol; import org.jenkinsci.plugins.p4.PerforceScm; import org.jenkinsci.plugins.p4.browsers.P4Browser; import org.jenkinsci.plugins.p4.populate.GraphHybridImpl; import org.jenkinsci.plugins.p4.populate.Populate; import org.jenkinsci.plugins.p4.workspace.Workspace; import org.kohsuke.stapler.DataBoundConstructor; import java.io.IOException; import java.util.ArrayList; import java.util.List; public class GlobalLibrarySCMSource extends AbstractP4SCMSource { private final String path; public String getPath() { return path; } @DataBoundConstructor public GlobalLibrarySCMSource(String credential, String charset, String path) { super(credential); this.path = path; setCharset(charset); setFormat("jenkins-library-${NODE_NAME}-${JOB_NAME}"); } @Override protected SCMRevision retrieve(@NonNull final String thingName, @NonNull TaskListener listener) throws IOException, InterruptedException { try { P4Path p4Path = new P4Path(path, thingName); P4SCMHead head = new P4SCMHead(thingName, p4Path); SCMRevision revision = getRevision(head, listener); return revision; } catch (Exception e) { throw new IOException(e.getMessage()); } } // Not used for Global Library @Override public P4Browser getBrowser() { return null; } @Override public List<P4SCMHead> getHeads(@NonNull TaskListener listener) throws Exception { // not used return new ArrayList<>(); } @Override public List<P4SCMHead> getTags(@NonNull TaskListener listener) throws Exception { // not used return new ArrayList<>(); } @Override public PerforceScm build(@NonNull SCMHead head, SCMRevision revision) { if (head instanceof P4SCMHead && revision instanceof P4SCMRevision) { P4SCMHead perforceHead = (P4SCMHead) head; P4SCMRevision perforceRevision = (P4SCMRevision) revision; // Build workspace from 'head' paths P4Path path = perforceHead.getPath(); Workspace workspace = getWorkspace(path); // Build populate from revision String pin = perforceRevision.getRef().toString(); Populate populate = new GraphHybridImpl(true, pin, null); PerforceScm scm = new PerforceScm(getCredential(), workspace, null, populate, getBrowser()); return scm; } else { throw new IllegalArgumentException("SCMHead and/or SCMRevision not a Perforce instance!"); } } @Extension @Symbol("globalLib") public static final class DescriptorImpl extends P4SCMSourceDescriptor { @Override public String getDisplayName() { return "Helix Library"; } } }
# | Change | User | Description | Committed | |
---|---|---|---|---|---|
#18 | 26602 | Paul Allen |
Reuse temp client connections for the multi-branch scan. TempClientHelper is set in retrieve and updated for different heads. |
||
#17 | 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 '...' |
||
#16 | 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 |
||
#15 | 24968 | Paul Allen |
Merge pull request #85 from DrakkenWulf/master Fix ability to do Replay in Pipelines. JENKINS-55107 |
||
#14 | 24841 | Paul Allen |
Merge pull request #81 from p4charu/jenkinsci-master Hide Helix Library from Add Source option in MultiBranch. |
||
#13 | 24780 | Paul Allen |
Merge pull request #80 from p4charu/master Fix and a test for concurrent global libraries using perforce workspaces. JENKINS-50975 |
||
#12 | 24777 | Paul Allen |
Global Library to use UUID for client name and delete after use. Add a new 'Delete the Perforce Client after checkout' option (for Manual clients) which normaly is false, but set to true for Global Library checkouts. JENKINS-50975 |
||
#11 | 24767 | Paul Allen |
Global Library support for multiple instances. Enforce a depot syntax path ending of "/..." Remove 'beta' from Global Library configuration. Generate a unique workspace to sync multiple Libraries. JENKINS-53922 |
||
#10 | 24662 | Paul Allen |
Undo *SCMSource rename to original *ScmSource. Reslove configuration loading issue due to 1.9.0 bad release. |
||
#9 | 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'. |
||
#8 | 24501 | Paul Allen | Refactor to use P4SCMXxx naming convention. | ||
#7 | 24497 | Paul Allen |
Force use of revision for Head. Update P4Head->P4Path revision with P4Revision to avoid builds on unbounded 'latest'. |
||
#6 | 24454 | Paul Allen |
Exclude and Include mapping support. Refactored P4Path usage and added P4SwarmPath. JENKINS-49804 |
||
#5 | 24267 | Paul Allen |
Use JOB_NAME in the Global Library Workspace name. Global Library workspaces must be unique. JENKINS-49525 JENKINS-50975 |
||
#4 | 23622 | Paul Allen |
Add Library path to client name for a unique SyncID. JENKINS-49047 |
||
#3 | 23320 | Paul Allen | Remove deprecated ID for SCMSource constructor. | ||
#2 | 22875 | Paul Allen | Refactor P4Path and Swarm API | ||
#1 | 22866 | Paul Allen |
Merge pull request #55 from jenkinsci/hth Global Pipeline Library support. JENKINS-46121 JENKINS-46550 |
||
//guest/perforce_software/p4jenkins/main/src/main/java/org/jenkinsci/plugins/p4/scm/GlobalLibrarySCMSource.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 | |
#8 | 24501 | Paul Allen | Refactor to use P4SCMXxx naming convention. | ||
#7 | 24497 | Paul Allen |
Force use of revision for Head. Update P4Head->P4Path revision with P4Revision to avoid builds on unbounded 'latest'. |
||
#6 | 24454 | Paul Allen |
Exclude and Include mapping support. Refactored P4Path usage and added P4SwarmPath. JENKINS-49804 |
||
#5 | 24267 | Paul Allen |
Use JOB_NAME in the Global Library Workspace name. Global Library workspaces must be unique. JENKINS-49525 JENKINS-50975 |
||
#4 | 23622 | Paul Allen |
Add Library path to client name for a unique SyncID. JENKINS-49047 |
||
#3 | 23320 | Paul Allen | Remove deprecated ID for SCMSource constructor. | ||
#2 | 22875 | Paul Allen | Refactor P4Path and Swarm API | ||
#1 | 22866 | Paul Allen |
Merge pull request #55 from jenkinsci/hth Global Pipeline Library support. JENKINS-46121 JENKINS-46550 |