package org.jenkinsci.plugins.p4.build; import hudson.EnvVars; import hudson.Extension; import hudson.model.Descriptor; import hudson.model.EnvironmentContributor; import hudson.model.Run; import hudson.model.TaskListener; import hudson.scm.SCM; import jenkins.model.Jenkins; import org.jenkinsci.plugins.p4.PerforceScm; import org.jenkinsci.plugins.p4.tagging.TagAction; import java.io.IOException; @Extension() public class P4EnvironmentContributor extends EnvironmentContributor { @Override public void buildEnvironmentFor(Run run, EnvVars env, TaskListener listener) throws IOException, InterruptedException { TagAction tagAction = TagAction.getLastAction(run); if (tagAction == null) { return; } // Set P4_CHANGELIST value if (tagAction.getRefChanges() != null) { String change = tagAction.getRefChange().toString(); env.put("P4_CHANGELIST", change); } // Set P4_CLIENT workspace value if (tagAction.getClient() != null) { String client = tagAction.getClient(); env.put("P4_CLIENT", client); } // Set P4_PORT connection if (tagAction.getPort() != null) { String port = tagAction.getPort(); env.put("P4_PORT", port); } // Set P4_USER connection if (tagAction.getUser() != null) { String user = tagAction.getUser(); env.put("P4_USER", user); } // Set P4_TICKET connection Jenkins j = Jenkins.getInstance(); if (j != null) { @SuppressWarnings("unchecked") Descriptor<SCM> scm = j.getDescriptor(PerforceScm.class); PerforceScm.DescriptorImpl p4scm = (PerforceScm.DescriptorImpl) scm; if (tagAction.getTicket() != null && !p4scm.isHideTicket()) { String ticket = tagAction.getTicket(); env.put("P4_TICKET", ticket); } } } }
# | Change | User | Description | Committed | |
---|---|---|---|---|---|
#4 | 22326 | Paul Allen | Merging down using p4-jenkins | ||
#3 | 22004 | Paul Allen | Store P4Ref graph changes for polling. | ||
#2 | 21978 | Paul Allen | Reporting Graph | ||
#1 | 21940 | Paul Allen | Branching using p4-jenkins | ||
//guest/perforce_software/p4jenkins/main/src/main/java/org/jenkinsci/plugins/p4/build/P4EnvironmentContributor.java | |||||
#3 | 21372 | Paul Allen |
Support custom SyncID. Exclude BUILD_NUMBER from SyncID. Pushed logging to higher level, so it is not reporting TagActions when building the Environment. JENKINS-40460 |
||
#2 | 21207 | Paul Allen |
Multi client support in Pipeline. If two or more `p4sync` operations are called in one Pipeline script, they MUST have different client names. During a build, multiple entries are added to the build history; on subsequent builds they are used in the three following situations: - Polling: largest change number across all the checkouts is used. - Change Summary: last change with the same client name is used. - Environment: last change recorded (regardless of client). Added two test cases to cover basic multi sync build/poll situations. JENKINS-38401 JENKINS-37462 JENKINS-39652 |
||
#1 | 21133 | Paul Allen |
P4 Environment Variables for pipeline. JENKINS-37584 |