Skip to content
Permalink
Browse files

Merge pull request #55 from tfennelly/BuildStep-Job-v2

[FIXED JENKINS-24887] CopyArtifact to implement workflow SimpleBuildStep
  • Loading branch information...
ikedam committed Jan 22, 2015
2 parents eda8035 + 73d6a05 commit 325f16adb3fc4f5d587b687bcb94b1726eeb033a
@@ -3,4 +3,10 @@ work
.classpath
.project
.settings

# IntelliJ project files
*.iml
*.iws
*.ipr
.idea
out
56 pom.xml
@@ -4,7 +4,7 @@
<parent>
<groupId>org.jenkins-ci.plugins</groupId>
<artifactId>plugin</artifactId>
<version>1.509</version>
<version>1.580.1</version>
</parent>

<artifactId>copyartifact</artifactId>
@@ -21,12 +21,23 @@
</license>
</licenses>

<properties>
<workflow.version>1.1</workflow.version>
</properties>

<dependencies>
<dependency>
<groupId>org.jenkins-ci.main</groupId>
<artifactId>maven-plugin</artifactId>
<version>1.509</version>
<version>2.7.1</version>
<optional>true</optional>
<exclusions>
<!-- See https://issues.jenkins-ci.org/browse/JENKINS-25625 -->
<exclusion>
<groupId>org.jenkins-ci</groupId>
<artifactId>SECURITY-144-compat</artifactId>
</exclusion>
</exclusions>
</dependency>
<!-- Used for UI test -->
<dependency>
@@ -35,6 +46,47 @@
<version>4.0</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.jenkins-ci.plugins</groupId>
<artifactId>matrix-project</artifactId>
<version>1.4</version>
</dependency>
<dependency>
<groupId>org.jenkins-ci.plugins.workflow</groupId>
<artifactId>workflow-job</artifactId>
<version>${workflow.version}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.jenkins-ci.plugins.workflow</groupId>
<artifactId>workflow-basic-steps</artifactId>
<version>${workflow.version}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.jenkins-ci.plugins.workflow</groupId>
<artifactId>workflow-cps</artifactId>
<version>${workflow.version}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.jenkins-ci.plugins.workflow</groupId>
<artifactId>workflow-durable-task-step</artifactId>
<version>${workflow.version}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.mockito</groupId>
<artifactId>mockito-core</artifactId>
<version>1.9.5</version>
<scope>test</scope>
<exclusions>
<exclusion>
<groupId>org.hamcrest</groupId>
<artifactId>hamcrest-core</artifactId>
</exclusion>
</exclusions>
</dependency>
</dependencies>
<build>
<plugins>
@@ -2,6 +2,7 @@

import hudson.ExtensionPoint;
import hudson.FilePath;
import hudson.Util;
import hudson.model.AbstractBuild;
import hudson.model.Run;

@@ -27,15 +28,42 @@

/**
* Called before copy-artifact operation.
*
* @param src
* The build record from which we are copying artifacts.
* @param dst
* The built into which we are copying artifacts.
* @param srcDir Source for upcoming file copy
* @param baseTargetDir Base target dir for upcoming file copy (the copy-artifact
* build step may later specify a deeper target dir)
*
* @since TODO ?
*/
public void initialize(Run<?, ?> src, Run<?, ?> dst, FilePath srcDir, FilePath baseTargetDir) throws IOException, InterruptedException {
if (dst instanceof AbstractBuild && Util.isOverridden(Copier.class, getClass(), "init", Run.class, AbstractBuild.class, FilePath.class, FilePath.class)) {
init(src, (AbstractBuild<?,?>) dst, srcDir, baseTargetDir);
} else {
throw new AbstractMethodError(String.format("Invalid call to Copier.initialize(Run src, Run dst, FilePath, FilePath), passing an AbstractBuild " +
"instance for the 'dst' arg when %s does not implement the deprecated version of 'init' that takes an AbstractBuild. Please supply a " +
"Run instance for the 'dst' arg.", getClass().getName()));
}
}

/**
* @deprecated Please use {@link #initialize(hudson.model.Run, hudson.model.Run, hudson.FilePath, hudson.FilePath)}
*/
public abstract void init(Run src, AbstractBuild<?,?> dst, FilePath srcDir, FilePath baseTargetDir) throws IOException, InterruptedException;
@Deprecated
public void init(Run src, AbstractBuild<?,?> dst, FilePath srcDir, FilePath baseTargetDir) throws IOException, InterruptedException {
if (Util.isOverridden(Copier.class, getClass(), "initialize", Run.class, Run.class, FilePath.class, FilePath.class)) {
initialize((Run<?, ?>)src, dst, srcDir, baseTargetDir);
} else {
// Is near impossible for this to happen. Copier impl would need to not implement the newer version of the initialize method, while at
// the same time be changed to call super with a Run instance for dst, which would be bizarre because that could only have been done
// after the initialize method was changed to not be abstract.
throw new AbstractMethodError(String.format("Invalid call to Copier.init(Run src, AbstractBuild dst, FilePath, FilePath). " +
"%s implements the newer version of 'initialize' that takes a Run instance for the 'dst' arg. Please call that implementation.", getClass().getName()));
}
}

/**
* @deprecated
@@ -110,7 +138,7 @@ public void end() throws IOException, InternalError {}
* Creates a clone.
*
* This method is only called before the {@link #init(Run, AbstractBuild, FilePath, FilePath)} method
* to allow each init-end session to run against different objects, so you need not copy any state
* to allow each initialize-end session to run against different objects, so you need not copy any state
* that your {@link Copier} might maintain.
*
* This is a cheap hack to implement a factory withot breaking backward compatibility.

0 comments on commit 325f16a

Please sign in to comment.
You can’t perform that action at this time.