package org.jenkinsci.plugins.p4.workflow; import com.google.common.collect.ImmutableSet; import hudson.Extension; import hudson.FilePath; import hudson.Launcher; import hudson.model.Item; import hudson.model.Run; import hudson.model.TaskListener; import hudson.util.FormValidation; import hudson.util.ListBoxModel; import org.jenkinsci.Symbol; import org.jenkinsci.plugins.p4.credentials.P4CredentialsImpl; import org.jenkinsci.plugins.p4.publish.Publish; import org.jenkinsci.plugins.p4.publish.PublishNotifierStep; import org.jenkinsci.plugins.p4.workspace.Workspace; import org.jenkinsci.plugins.workflow.steps.Step; import org.jenkinsci.plugins.workflow.steps.StepContext; import org.jenkinsci.plugins.workflow.steps.StepDescriptor; import org.jenkinsci.plugins.workflow.steps.StepExecution; import org.jenkinsci.plugins.workflow.steps.SynchronousNonBlockingStepExecution; import org.kohsuke.stapler.AncestorInPath; import org.kohsuke.stapler.DataBoundConstructor; import org.kohsuke.stapler.QueryParameter; import javax.annotation.Nonnull; import java.util.Set; public class P4PublishStep extends Step { private final String credential; private final Workspace workspace; private final Publish publish; public String getCredential() { return credential; } public Workspace getWorkspace() { return workspace; } public Publish getPublish() { return publish; } @DataBoundConstructor public P4PublishStep(String credential, Workspace workspace, Publish publish) { this.credential = credential; this.workspace = workspace; this.publish = publish; } @Override public StepExecution start(StepContext context) throws Exception { return new P4PublishStepExecution(this, context); } @Extension(optional = true) @Symbol("publish") public static final class DescriptorImpl extends StepDescriptor { @Override public String getFunctionName() { return "p4publish"; } @Override public String getDisplayName() { return "P4 Publish"; } @Override public Set<? extends Class<?>> getRequiredContext() { return ImmutableSet.of(Run.class, FilePath.class, Launcher.class, TaskListener.class); } public ListBoxModel doFillCredentialItems(@AncestorInPath Item project, @QueryParameter String credential) { return P4CredentialsImpl.doFillCredentialItems(project, credential); } public FormValidation doCheckCredential(@AncestorInPath Item project, @QueryParameter String value) { return P4CredentialsImpl.doCheckCredential(project, value); } } public static class P4PublishStepExecution extends SynchronousNonBlockingStepExecution<Void> { private static final long serialVersionUID = 1L; private transient P4PublishStep step; protected P4PublishStepExecution(P4PublishStep step, @Nonnull StepContext context) { super(context); this.step = step; } @Override protected Void run() throws Exception { PublishNotifierStep notifier = new PublishNotifierStep(step.getCredential(), step.getWorkspace(), step.getPublish()); notifier.perform(getContext().get(Run.class), getContext().get(FilePath.class), getContext().get(Launcher.class), getContext().get(TaskListener.class)); return null; } } }
# | Change | User | Description | Committed | |
---|---|---|---|---|---|
#2 | 23685 | Paul Allen | Copy main -> dev | ||
#1 | 20641 | Paul Allen | Copy main -> dev (jenkinsci/p4-plugin) | ||
//guest/perforce_software/p4jenkins/main/src/main/java/org/jenkinsci/plugins/p4/workflow/P4PublishStep.java | |||||
#3 | 16510 | Paul Allen | Move AssetNotifier* to Publish and rename. | ||
#2 | 15403 | Paul Allen |
Perforce triggered polling BETA. Perforce triggers on a change-submit and sends a POST to the endpoint http://${JENKINS}/p4/change with the data: {"change":"12345","p4port":"localhost:1666"} Note: ‘change’ is not used (yet), but ‘p4port’ MUST match the credential in the Jenkins Job. JENKINS-25249 |
||
#1 | 15394 | Paul Allen |
Workflow-DSL functionality. Tested workflow DSL against 1.596.1 older functionality tested against 1.580.1 @sven_erik_knop |
||
//guest/sven_erik_knop/p4jenkins/src/main/java/org/jenkinsci/plugins/p4/workflow/P4PublishStep.java | |||||
#1 | 14892 | Sven Erik Knop |
Add p4publish as the last p4 step puzzle piece. Interesting snippet: node { p4sync credential: '634a31d2-bd60-4c39-bf84-b09f057c5431', template: 'jenkins' p4tag rawLabelDesc: 'Jenkins post-build label - from DSL!.', rawLabelName: 'jenkins-{BUILDTAG}' publisher = [$class: 'SubmitImpl', description: 'Submitted by Jenkins. Build: ${BUILD_TAG}', onlyOnSuccess: false, reopen: false] buildWorkspace = [$class: 'StreamWorkspaceImpl', charset: 'none', format: 'jenkins-${NODE_NAME}-${JOB_NAME}', pinHost: false, streamName: '//stream/main'] p4publish credential: '634a31d2-bd60-4c39-bf84-b09f057c5431', publish: publisher, workspace: buildWorkspace } Makes it easier to read. |