Skip to content

Commit

Permalink
[JENKINS-32493] Adapt to Parent POM 2.3 and JTH 2.1
Browse files Browse the repository at this point in the history
  • Loading branch information
Andres Rodriguez committed Feb 3, 2016
1 parent f0f5cd7 commit 75b91e5
Show file tree
Hide file tree
Showing 14 changed files with 202 additions and 88 deletions.
81 changes: 42 additions & 39 deletions pom.xml
Expand Up @@ -4,7 +4,7 @@
<parent>
<groupId>org.jenkins-ci.plugins</groupId>
<artifactId>plugin</artifactId>
<version>1.580.1</version>
<version>2.3</version>
</parent>

<artifactId>copyartifact</artifactId>
Expand All @@ -22,7 +22,9 @@
</licenses>

<properties>
<workflow.version>1.1</workflow.version>
<jenkins.version>1.580.1</jenkins.version>
<java.level>6</java.level>
<workflow.version>1.1</workflow.version>
</properties>

<dependencies>
Expand Down Expand Up @@ -52,6 +54,12 @@
</exclusions>
</dependency>
<!-- Used for UI test -->
<dependency>
<groupId>org.jenkins-ci.main</groupId>
<artifactId>jenkins-test-harness-tools</artifactId>
<version>2.0</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.jenkins-ci.plugins</groupId>
<artifactId>cloudbees-folder</artifactId>
Expand All @@ -63,6 +71,24 @@
<artifactId>matrix-project</artifactId>
<version>1.3</version>
</dependency>
<dependency>
<groupId>org.jenkins-ci.plugins</groupId>
<artifactId>junit</artifactId>
<version>1.10</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.jenkins-ci.plugins</groupId>
<artifactId>credentials</artifactId>
<version>1.24</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.jenkins-ci.plugins</groupId>
<artifactId>matrix-auth</artifactId>
<version>1.2</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.jenkins-ci.plugins.workflow</groupId>
<artifactId>workflow-job</artifactId>
Expand Down Expand Up @@ -99,31 +125,7 @@
</exclusion>
</exclusions>
</dependency>
<!-- to suppress known (and harmless) findbugs issues -->
<dependency>
<groupId>com.google.code.findbugs</groupId>
<artifactId>annotations</artifactId>
<version>3.0.0</version>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.jenkins-ci.tools</groupId>
<artifactId>maven-hpi-plugin</artifactId>
<version>1.95</version>
</plugin>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>findbugs-maven-plugin</artifactId>
<version>3.0.1</version>
<configuration>
<xmlOutput>true</xmlOutput>
<failOnError>false</failOnError>
</configuration>
</plugin>
</plugins>
</build>
<reporting>
<plugins>
<plugin>
Expand All @@ -147,19 +149,20 @@
<tag>HEAD</tag>
</scm>

<repositories>
<repository>
<id>repo.jenkins-ci.org</id>
<url>http://repo.jenkins-ci.org/public/</url>
</repository>
</repositories>
<repositories>
<repository>
<id>repo.jenkins-ci.org</id>
<url>http://repo.jenkins-ci.org/public/</url>
</repository>
</repositories>

<pluginRepositories>
<pluginRepository>
<id>repo.jenkins-ci.org</id>
<url>http://repo.jenkins-ci.org/public/</url>
</pluginRepository>
</pluginRepositories>

<pluginRepositories>
<pluginRepository>
<id>repo.jenkins-ci.org</id>
<url>http://repo.jenkins-ci.org/public/</url>
</pluginRepository>
</pluginRepositories>
</project>
</project>


13 changes: 9 additions & 4 deletions src/main/java/hudson/plugins/copyartifact/BuildSelector.java
Expand Up @@ -67,7 +67,11 @@ public Run<?,?> getBuild(Job<?,?> job, EnvVars env, BuildFilter filter, Run<?,?>
}

/**
* Older version of API.
* Find a build to copy artifacts from. Older and deprecated version of API.
* @param job Source project
* @param env Environment for build that is copying artifacts
* @param filter Additional filter; returned result should return true (return null otherwise)
* @return Build to use, or null if no appropriate build was found
*/
@Deprecated
public Run<?,?> getBuild(Job<?,?> job, EnvVars env, BuildFilter filter) {
Expand All @@ -91,9 +95,10 @@ protected boolean isSelectable(Run<?,?> run, EnvVars env) {
* Returns <code>false</code> if <code>run</code> is <code>null</code>
* or <code>run</code> is still running.
*
* @param run
* @param resultToTest
* @return
* @param run Build to test.
* @param resultToTest Result to test.
* @return <code>false</code> if <code>run</code> is <code>null</code>
* or <code>run</code> is still running.
* @see Result#isBetterOrEqualTo(Result)
*/
protected static boolean isBuildResultBetterOrEqualTo(Run<?,?> run, Result resultToTest) {
Expand Down
Expand Up @@ -27,6 +27,7 @@
import java.util.List;
import java.util.logging.Logger;

import com.thoughtworks.xstream.XStreamException;
import jenkins.model.Jenkins;
import hudson.DescriptorExtensionList;
import hudson.Extension;
Expand Down Expand Up @@ -84,7 +85,10 @@ private StringParameterValue toStringValue(BuildSelector selector) {

/**
* Convert xml fragment into a BuildSelector object.
* @throws XStreamException or ClassCastException if input is invalid
* @param xml XML fragment to parse.
* @return the BuildSelector represented by the input XML.
* @throws XStreamException if the object cannot be deserialized
* @throws ClassCastException if input is invalid
*/
public static BuildSelector getSelectorFromXml(String xml) {
return (BuildSelector)XSTREAM.fromXML(xml);
Expand Down
50 changes: 47 additions & 3 deletions src/main/java/hudson/plugins/copyartifact/Copier.java
Expand Up @@ -37,6 +37,8 @@ public abstract class Copier implements ExtensionPoint {
* @param baseTargetDir Base target dir for upcoming file copy (the copy-artifact
* build step may later specify a deeper target dir)
*
* @throws IOException if an error occurs while performing the operation.
* @throws InterruptedException if any thread interrupts the current thread.
* @since TODO ?
*/
public void initialize(Run<?, ?> src, Run<?, ?> dst, FilePath srcDir, FilePath baseTargetDir) throws IOException, InterruptedException {
Expand All @@ -50,6 +52,18 @@ public void initialize(Run<?, ?> src, Run<?, ?> dst, FilePath srcDir, FilePath b
}

/**
* 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)
*
* @throws IOException if an error occurs while performing the operation.
* @throws InterruptedException if any thread interrupts the current thread.
* @deprecated Please use {@link #initialize(hudson.model.Run, hudson.model.Run, hudson.FilePath, hudson.FilePath)}
*/
@Deprecated
Expand All @@ -66,15 +80,33 @@ public void init(Run src, AbstractBuild<?,?> dst, FilePath srcDir, FilePath base
}

/**
* @deprecated
* Copy files matching the given file mask to the specified target.
*
* @param srcDir Source directory
* @param filter Ant GLOB pattern
* @param targetDir Target directory
* @return Number of files that were copied
* @throws IOException if an error occurs while performing the operation.
* @throws InterruptedException if any thread interrupts the current thread.
* @deprecated
* call/override {@link #copyAll(FilePath srcDir, String filter, String excludes, FilePath targetDir, boolean fingerprintArtifacts)} instead.
*/
@Deprecated
public int copyAll(FilePath srcDir, String filter, FilePath targetDir) throws IOException, InterruptedException {
return copyAll(srcDir, filter, null, targetDir, true);
}

/**
* @deprecated
* Copy files matching the given file mask to the specified target.
*
* @param srcDir Source directory
* @param filter Ant GLOB pattern
* @param targetDir Target directory
* @param fingerprintArtifacts boolean controlling if the copy should also fingerprint the artifacts
* @return Number of files that were copied
* @throws IOException if an error occurs while performing the operation.
* @throws InterruptedException if any thread interrupts the current thread.
* @deprecated
* call/override {@link #copyAll(FilePath, String, String, FilePath, boolean)} instead.
*/
@Deprecated
Expand All @@ -92,6 +124,8 @@ public int copyAll(FilePath srcDir, String filter, FilePath targetDir, boolean f
* @param excludes Ant GLOB pattern. Can be null.
* @param targetDir Target directory
* @param fingerprintArtifacts boolean controlling if the copy should also fingerprint the artifacts
* @throws IOException if an error occurs while performing the operation.
* @throws InterruptedException if any thread interrupts the current thread.
* @return Number of files that were copied
* @see FilePath#copyRecursiveTo(String,FilePath)
*/
Expand All @@ -112,9 +146,16 @@ public int copyAll(FilePath srcDir, String filter, String excludes, FilePath tar
}

/**
* @deprecated
* Copy a single file.
* @param source Source file
* @param target Target file (includes filename; this is not the target directory).
* Directory for target should already exist (copy-artifact build step calls mkdirs).
* @throws IOException if an error occurs while performing the operation.
* @throws InterruptedException if any thread interrupts the current thread.
* @deprecated
* call/override {@link #copyOne(FilePath source, FilePath target, boolean fingerprintArtifacts)} instead.
*/
@Deprecated
public void copyOne(FilePath source, FilePath target) throws IOException, InterruptedException {
copyOne(source, target, true);
}
Expand All @@ -125,12 +166,15 @@ public void copyOne(FilePath source, FilePath target) throws IOException, Interr
* @param target Target file (includes filename; this is not the target directory).
* Directory for target should already exist (copy-artifact build step calls mkdirs).
* @param fingerprintArtifacts boolean controlling if the copy should also fingerprint the artifacts
* @throws IOException if an error occurs while performing the operation.
* @throws InterruptedException if any thread interrupts the current thread.
* @see FilePath#copyTo(FilePath)
*/
public abstract void copyOne(FilePath source, FilePath target, boolean fingerprintArtifacts) throws IOException, InterruptedException;

/**
* Ends what's started by the {@link #init(Run, AbstractBuild, FilePath, FilePath)} method.
* @throws IOException if an error occurs while performing the operation.
*/
public void end() throws IOException, InternalError {}

Expand Down
Expand Up @@ -203,7 +203,7 @@ public void setFingerprintArtifacts(boolean fingerprintArtifacts) {
/**
* Set the suffix for variables to store copying results.
*
* @param resultVariableSuffix
* @param resultVariableSuffix Variable suffix to use.
*/
@DataBoundSetter
public void setResultVariableSuffix(String resultVariableSuffix) {
Expand Down
Expand Up @@ -30,7 +30,7 @@
import java.util.List;
import java.util.regex.Pattern;

import hudson.model.Job;
import hudson.model.Job;
import jenkins.model.Jenkins;
import net.sf.json.JSONObject;

Expand Down Expand Up @@ -95,7 +95,7 @@ public CopyArtifactPermissionProperty(String projectNames) {
* @param copier a project who wants to copy artifacts of this project.
* @return whether copier is allowed to copy artifacts of this project.
*/
public boolean canCopiedBy(Job<?,?> copier) {
public boolean canCopiedBy(Job<?,?> copier) {
String copierName = copier.getRelativeNameFrom(owner.getParent());
String absoluteName = String.format("/%s", copier.getFullName());
// Note: getFullName() returns not an absolute path, but a relative path from root...
Expand Down Expand Up @@ -133,13 +133,13 @@ public String apply(String input) {
}

/**
* Convenient wrapper for {@link CopyArtifactPermissionProperty#canCopiedBy(Job)}
* Convenient wrapper for {@link CopyArtifactPermissionProperty#canCopiedBy(Job)}
*
* @param copier a project that wants to copy artifacts of copiee.
* @param copiee a owner of artifacts.
* @return whether copier can copy artifacts of copiee.
*/
public static boolean canCopyArtifact(Job<?,?> copier, Job<?,?> copiee) {
public static boolean canCopyArtifact(Job<?,?> copier, Job<?,?> copiee) {
CopyArtifactPermissionProperty prop = copiee.getProperty(CopyArtifactPermissionProperty.class);
if (prop == null) {
return false;
Expand Down Expand Up @@ -169,10 +169,11 @@ public String getPropertyName() {
}

/**
* @param req
* @param formData
* @return
* @throws hudson.model.Descriptor.FormException
* Creates a new property.
* @param req Request.
* @param formData Form data.
* @return The created property.
* @throws hudson.model.Descriptor.FormException If an error occurs parsing the form data.
* @see hudson.model.JobPropertyDescriptor#newInstance(org.kohsuke.stapler.StaplerRequest, net.sf.json.JSONObject)
*/
@Override
Expand Down Expand Up @@ -222,8 +223,10 @@ public CopyArtifactPermissionProperty newInstance(StaplerRequest req, JSONObject
}

/**
* @param projectNames
* @return
* Checks the provided projects exist in the provided context.
* @param projectNames Projects to check.
* @param context Context.
* @return ok if all projects are found and a warning otherwise.
*/
public FormValidation doCheckProjectNames(@QueryParameter String projectNames, @AncestorInPath ItemGroup<?> context) {
List<String> notFound = checkNotFoundProjects(projectNames, context);
Expand All @@ -234,9 +237,10 @@ public FormValidation doCheckProjectNames(@QueryParameter String projectNames, @
}

/**
* @param value
* @param context
* @return
* Provides candidates for project name autocompletion.
* @param value Seed value.
* @param context Context.
* @return The proposed project candidates.
*/
public AutoCompletionCandidates doAutoCompleteProjectNames(@QueryParameter String value, @AncestorInPath ItemGroup<?> context) {
AutoCompletionCandidates candidates = new AutoCompletionCandidates();
Expand Down

0 comments on commit 75b91e5

Please sign in to comment.