PublishNotifierStep.java #3

  • //
  • guest/
  • perforce_software/
  • p4jenkins/
  • dev/
  • src/
  • main/
  • java/
  • org/
  • jenkinsci/
  • plugins/
  • p4/
  • publish/
  • PublishNotifierStep.java
  • View
  • Commits
  • Open Download .zip Download (2 KB)
package org.jenkinsci.plugins.p4.publish;

import hudson.FilePath;
import hudson.Launcher;
import hudson.model.Result;
import hudson.model.Run;
import hudson.model.TaskListener;
import hudson.tasks.BuildStepMonitor;
import jenkins.tasks.SimpleBuildStep;
import org.jenkinsci.plugins.p4.tasks.PublishTask;
import org.jenkinsci.plugins.p4.workspace.Workspace;
import org.kohsuke.stapler.DataBoundConstructor;

import java.io.IOException;

public class PublishNotifierStep extends PublishNotifier implements SimpleBuildStep {

	@DataBoundConstructor
	public PublishNotifierStep(String credential, Workspace workspace,
	                           Publish publish) {
		super(credential, workspace, publish);
	}

	@Override
	public BuildStepMonitor getRequiredMonitorService() {
		return BuildStepMonitor.NONE;
	}

	@Override
	public void perform(Run<?, ?> run, FilePath buildWorkspace,
	                    Launcher launcher, TaskListener listener)
			throws InterruptedException, IOException {

		// return early if publish not required
		if (getPublish().isOnlyOnSuccess() && run.getResult() != Result.SUCCESS) {
			return;
		}

		Workspace ws = (Workspace) getWorkspace().clone();

		// Create task
		PublishTask task = new PublishTask(getCredential(), run, listener, getPublish());
		ws = task.setEnvironment(run, ws, buildWorkspace);
		task.setWorkspace(ws);

		// Expand description
		String desc = getPublish().getDescription();
		desc = ws.getExpand().format(desc, false);
		getPublish().setExpandedDesc(desc);

		buildWorkspace.act(task);
	}
}
# Change User Description Committed
#3 23686 Paul Allen Cleanup P4Task: Move setters into constructor.
#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/publish/PublishNotifierStep.java
#2 19762 Paul Allen Missing Override annotations.
#1 16510 Paul Allen Move AssetNotifier* to Publish and rename.
//guest/perforce_software/p4jenkins/main/src/main/java/org/jenkinsci/plugins/p4/asset/AssetNotifierStep.java
#1 15394 Paul Allen Workflow-DSL functionality.

Tested workflow DSL against 1.596.1 older functionality tested against 1.580.1
@sven_erik_knop