package org.jenkinsci.plugins.p4.scm; import edu.umd.cs.findbugs.annotations.CheckForNull; import edu.umd.cs.findbugs.annotations.NonNull; import hudson.EnvVars; import hudson.Extension; import hudson.model.Item; import hudson.model.Run; import hudson.scm.SCM; import hudson.scm.SCMDescriptor; import hudson.util.LogTaskListener; import jenkins.scm.api.SCMFile; import jenkins.scm.api.SCMFileSystem; import jenkins.scm.api.SCMRevision; import jenkins.scm.api.SCMSource; import jenkins.scm.api.SCMSourceDescriptor; import org.jenkinsci.plugins.p4.PerforceScm; import org.jenkinsci.plugins.p4.client.TempClientHelper; import org.jenkinsci.plugins.p4.workspace.Workspace; import org.jenkinsci.plugins.workflow.job.WorkflowJob; import java.io.IOException; import java.util.logging.Level; import java.util.logging.Logger; public class P4SCMFileSystem extends SCMFileSystem { private static Logger logger = Logger.getLogger(P4SCMFileSystem.class.getName()); private TempClientHelper p4; protected P4SCMFileSystem(@NonNull Item owner, @NonNull PerforceScm scm, @CheckForNull P4SCMRevision rev) throws Exception { super(rev); String credential = scm.getCredential(); Workspace ws = scm.getWorkspace().deepClone(); // Set environment in Workspace if (owner instanceof WorkflowJob) { WorkflowJob _job = (WorkflowJob) owner; Run<?,?> build = _job.getLastBuild(); EnvVars env = build.getEnvironment(new LogTaskListener(logger, Level.INFO)); ws.setExpand(env); } this.p4 = new TempClientHelper(owner, credential, null, ws); } @Override public void close() throws IOException { p4.close(); } @Override public long lastModified() throws IOException, InterruptedException { return 0; } @Override public SCMFile getRoot() { return new P4SCMFile(this); } @Extension public static class BuilderImpl extends SCMFileSystem.Builder { @Override public boolean supports(SCM source) { if (source instanceof PerforceScm) { return true; } return false; } @Override public boolean supports(SCMSource source) { if (source instanceof AbstractP4ScmSource) { return true; } return false; } @Override protected boolean supportsDescriptor(SCMDescriptor scmDescriptor) { return false; } @Override protected boolean supportsDescriptor(SCMSourceDescriptor scmSourceDescriptor) { return false; } @Override public SCMFileSystem build(@NonNull Item owner, SCM scm, @CheckForNull SCMRevision rev) throws IOException, InterruptedException { if (scm == null || !(scm instanceof PerforceScm)) { return null; } PerforceScm p4scm = (PerforceScm) scm; if (rev != null && !(rev instanceof P4SCMRevision)) { return null; } P4SCMRevision p4rev = (P4SCMRevision) rev; try { return new P4SCMFileSystem(owner, p4scm, p4rev); } catch (Exception e) { throw new IOException(e); } } } public TempClientHelper getConnection() { return p4; } }
# | Change | User | Description | Committed | |
---|---|---|---|---|---|
#9 | 28865 | Paul Allen |
Merge pull request #146 from skumar7322/dependencyUpdate Update Jenkins version to 2.138.4 |
||
#8 | 25656 | Paul Allen | Fix findbug errors, and add logger. | ||
#7 | 25655 | Paul Allen |
Extract the Job Environment when fetching the Jenkinsfile. Allow Parameterized builds for the Stream field when using 'Pipline Script from SCM'. JENKINS-56775 |
||
#6 | 24942 | Paul Allen |
Deep clone of Workspace objects. WorkspaceSpec was not cloned and caused the View to change. JENKINS-54695 |
||
#5 | 24842 | Paul Allen | Add logging for Client View field on Workspace update. | ||
#4 | 24830 | Paul Allen |
Preserve Pipeline client when using Lightweight checkout. Clone Workspace before creating Temp Client. JENKINS-54488 |
||
#3 | 24662 | Paul Allen |
Undo *SCMSource rename to original *ScmSource. Reslove configuration loading issue due to 1.9.0 bad release. |
||
#2 | 24501 | Paul Allen | Refactor to use P4SCMXxx naming convention. | ||
#1 | 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 |