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 | |
---|---|---|---|---|---|
#2 | 24662 | Paul Allen |
Undo *SCMSource rename to original *ScmSource. Reslove configuration loading issue due to 1.9.0 bad release. |
||
#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'. |
||
//guest/perforce_software/p4jenkins/main/src/main/java/org/jenkinsci/plugins/p4/scm/GlobalLibraryScmSource.java | |||||
#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 |