package org.jenkinsci.plugins.p4.client; import hudson.Extension; import hudson.FilePath; import hudson.Launcher; import hudson.model.AbstractProject; import hudson.model.Run; import hudson.model.TaskListener; import hudson.tasks.BuildStepDescriptor; import hudson.tasks.BuildStepMonitor; import hudson.tasks.Notifier; import hudson.tasks.Publisher; import jenkins.tasks.SimpleBuildStep; import org.jenkinsci.Symbol; import org.jenkinsci.plugins.p4.tagging.TagAction; import org.jenkinsci.plugins.p4.tasks.RemoveClientTask; import org.jenkinsci.plugins.p4.workspace.Workspace; import org.kohsuke.stapler.DataBoundConstructor; import java.io.IOException; import java.util.logging.Logger; public class CleanupNotifier extends Notifier implements SimpleBuildStep { protected static final Logger logger = Logger.getLogger(CleanupNotifier.class.getName()); public final boolean deleteClient; @DataBoundConstructor public CleanupNotifier(boolean deleteClient) { this.deleteClient = deleteClient; } @Override public BuildStepMonitor getRequiredMonitorService() { return BuildStepMonitor.NONE; } @Extension @Symbol("cleanup") public static final class DescriptorImpl extends BuildStepDescriptor<Publisher> { @Override @SuppressWarnings("rawtypes") public boolean isApplicable(Class<? extends AbstractProject> jobType) { return true; } @Override public String getDisplayName() { return "Perforce: Cleanup"; } } @Override public void perform(Run<?, ?> run, FilePath buildWorkspace, Launcher launcher, TaskListener listener) throws InterruptedException, IOException { TagAction tagAction = (TagAction) run.getAction(TagAction.class); String credential = tagAction.getCredential(); Workspace workspace = tagAction.getWorkspace(); // Setup Cleanup Task RemoveClientTask task = new RemoveClientTask(); task.setListener(listener); task.setCredential(credential, run); // Set workspace used for the Task Workspace ws = task.setEnvironment(run, workspace, buildWorkspace); task.setWorkspace(ws); buildWorkspace.act(task); } }
# | Change | User | Description | Committed | |
---|---|---|---|---|---|
#8 | 25736 | Paul Allen |
Cleanup step - use checkbox state and ignore Global option. The global options for deleting the client is ignored and the cleanup checkbox state is used. The Global option for deleting files still applies, but some what irrelevant as Jenkins can manage this in other steps. Note that the RemoveClientTask is used for cleaning up temp clients in polling and checkout steps as wall as deleting a Jenkins Job. JENKINS-47107 |
||
#7 | 24487 | Paul Allen | Perforce Connection Refactor. | ||
#6 | 22821 | Paul Allen |
Merge pull request #53 from jenkinsci/TagAction-order Get Last TagAction. JENKINS-37618 JENKINS-45613 |
||
#5 | 22818 | Paul Allen | Remove duplicate cleanup and add alias for old name. | ||
#4 | 22684 | Paul Allen | Added @Symbol to Extension classes for Pipeline Syntax. | ||
#3 | 22021 | Paul Allen |
Set environment to expand client name for Publish and Remove Client. JENKINS-43378 |
||
#2 | 21794 | Paul Allen |
Merge pull request #39 from Dohbedoh/JENKINS-34825 Jenkins 34825 |
||
#1 | 19806 | Paul Allen | Minor refactor for CleanupNotifier. | ||
//guest/perforce_software/p4jenkins/main/src/main/java/org/jenkinsci/plugins/p4/cleanup/CleanupNotifier.java | |||||
#1 | 19765 | Paul Allen |
A Post Build 'P4 Cleanup' with DSL support. Can be added as a PostBuild action to remove the client workspace spec. It uses the options set in the Global configuration to delete the Client Spec and/or Local Files. In DSL it can be called with `p4cleanup true`, other parameters may get added at a later date. JENKINS-35667 |