package org.jenkinsci.plugins.p4.publish; import hudson.Extension; import hudson.FilePath; import hudson.Launcher; import hudson.model.AbstractBuild; import hudson.model.AbstractProject; import hudson.model.BuildListener; import hudson.model.Item; import hudson.model.Result; import hudson.tasks.BuildStepDescriptor; import hudson.tasks.BuildStepMonitor; import hudson.tasks.Notifier; import hudson.tasks.Publisher; import hudson.util.ListBoxModel; import jenkins.model.Jenkins; import org.jenkinsci.Symbol; import org.jenkinsci.plugins.p4.credentials.P4CredentialsImpl; import org.jenkinsci.plugins.p4.tasks.PublishTask; import org.jenkinsci.plugins.p4.workspace.Workspace; import org.kohsuke.stapler.AncestorInPath; import org.kohsuke.stapler.DataBoundConstructor; import org.kohsuke.stapler.QueryParameter; import java.io.IOException; import java.util.logging.Logger; public class PublishNotifier extends Notifier { private static Logger logger = Logger.getLogger(PublishNotifier.class.getName()); 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 PublishNotifier(String credential, Workspace workspace, Publish publish) { this.credential = credential; this.workspace = workspace; this.publish = publish; } public BuildStepMonitor getRequiredMonitorService() { return BuildStepMonitor.NONE; } @Override public boolean perform(AbstractBuild<?, ?> build, Launcher launcher, BuildListener listener) throws InterruptedException, IOException { // return early if publish not required if (getPublish().isOnlyOnSuccess() && build.getResult() != Result.SUCCESS) { return true; } FilePath buildWorkspace = build.getWorkspace(); if (buildWorkspace == null) { logger.warning("FilePath is null!"); return false; } Workspace ws = (Workspace) getWorkspace().clone(); // Create task PublishTask task = new PublishTask(getPublish()); task.setListener(listener); task.setCredential(getCredential(), build); ws = task.setEnvironment(build, ws, buildWorkspace); task.setWorkspace(ws); // Expand description String desc = getPublish().getDescription(); desc = ws.getExpand().format(desc, false); getPublish().setExpandedDesc(desc); boolean success = buildWorkspace.act(task); return success; } public static DescriptorImpl descriptor() { Jenkins j = Jenkins.getInstance(); if (j != null) { j.getDescriptorByType(PublishNotifier.DescriptorImpl.class); } return null; } @Extension @Symbol("publish") public static final class DescriptorImpl extends BuildStepDescriptor<Publisher> { @Override public boolean isApplicable(Class<? extends AbstractProject> jobType) { return true; } @Override public String getDisplayName() { return "Perforce: Publish assets"; } public ListBoxModel doFillCredentialItems(@AncestorInPath Item project, @QueryParameter String credential) { return P4CredentialsImpl.doFillCredentialItems(project, credential); } } }
# | Change | User | Description | Committed | |
---|---|---|---|---|---|
#10 | 29212 | Paul Allen |
Merge pull request #160 from pschlan/JENKINS-69808 JENKINS-69808: Cleanup client after publish, if enabled |
||
#9 | 24942 | Paul Allen |
Deep clone of Workspace objects. WorkspaceSpec was not cloned and caused the View to change. JENKINS-54695 |
||
#8 | 24487 | Paul Allen | Perforce Connection Refactor. | ||
#7 | 22894 | Paul Allen |
(minor) remove Pipeline Library after test. Clean up after testGlobalLib and minor refactor on PublishNotifier and PublishNotifierStep. |
||
#6 | 22684 | Paul Allen | Added @Symbol to Extension classes for Pipeline Syntax. | ||
#5 | 22021 | Paul Allen |
Set environment to expand client name for Publish and Remove Client. JENKINS-43378 |
||
#4 | 21794 | Paul Allen |
Merge pull request #39 from Dohbedoh/JENKINS-34825 Jenkins 34825 |
||
#3 | 20986 | Paul Allen |
Ground work for MultiJob support. Pushed validate up to ConnectionHelper and added new Perforce functions. |
||
#2 | 19581 | Paul Allen | Minor fixes to satisfy FindBugs Analysis. | ||
#1 | 16510 | Paul Allen | Move AssetNotifier* to Publish and rename. | ||
//guest/perforce_software/p4jenkins/main/src/main/java/org/jenkinsci/plugins/p4/asset/AssetNotifier.java | |||||
#11 | 15656 | Paul Allen |
Updated credentials to extend BaseStandardCredentials. Allows users to set the ID at creation. JENKINS-29702 |
||
#10 | 15394 | Paul Allen |
Workflow-DSL functionality. Tested workflow DSL against 1.596.1 older functionality tested against 1.580.1 @sven_erik_knop |
||
#9 | 14035 | Paul Allen |
Publish on Success option. Added a checkbox to the Publish step to only shelve/submit change if the build succeeded. |
||
#8 | 13681 | Paul Allen |
Abstracted Expand class from Workspace. Added support for Label variable expansion in the name and description. |
||
#7 | 13603 | Paul Allen | Improved Error for Publish step when connection is down. | ||
#6 | 11334 | Paul Allen |
Remote slave support for Publish Perforce Publish commands need to be executed from the remote slave. - Includes refactoring into task package |
||
#5 | 11258 | Paul Allen |
Minor fix for Publish Asset Set client root for new workspaces. Flush client to populate have list (sync -k) |
||
#4 | 11249 | Paul Allen | Fix: Use cloned workspace not config. | ||
#3 | 11246 | Paul Allen | Create/Update client when using publish assets. | ||
#2 | 11236 | Paul Allen | Merge minor GitHub edit | ||
#1 | 11231 | Paul Allen |
Publish assets to Perforce. New feature to allow Jenkins to shelve or submit the build result to Perforce. Configured as a Post Build Step, the Perforce credential and workspace are required as the asset could be published to a different Perforce instance. |