diff --git a/pom.xml b/pom.xml
index 67061b44..2dccdb4e 100644
--- a/pom.xml
+++ b/pom.xml
@@ -4,7 +4,7 @@
org.jenkins-ci.plugins
plugin
- 3.10
+ 3.15
@@ -26,9 +26,9 @@
1.41
-SNAPSHOT
- 2.118
+ 2.121.1
8
- 2.28-rc333.0675e9e9cb4c
+ 2.28
true
@@ -44,6 +44,11 @@
structs
1.14
+
+ org.jenkins-ci.plugins
+ apache-httpcomponents-client-4-api
+ 4.5.5-3.0
+
org.jenkins-ci.main
diff --git a/src/main/java/hudson/plugins/copyartifact/CopyArtifact.java b/src/main/java/hudson/plugins/copyartifact/CopyArtifact.java
index e3cd891e..9baaf17a 100644
--- a/src/main/java/hudson/plugins/copyartifact/CopyArtifact.java
+++ b/src/main/java/hudson/plugins/copyartifact/CopyArtifact.java
@@ -52,6 +52,7 @@
import hudson.util.FormValidation;
import hudson.util.VariableResolver;
import hudson.util.XStream2;
+import io.jenkins.plugins.httpclient.RobustHTTPClient;
import java.io.File;
import java.io.FileOutputStream;
@@ -93,6 +94,7 @@
import jenkins.MasterToSlaveFileCallable;
import jenkins.util.VirtualFile;
import org.apache.commons.io.IOUtils;
+import org.apache.http.client.methods.HttpGet;
/**
* Build step to copy artifacts from another project.
@@ -598,9 +600,9 @@ private static String copyOne(VirtualFile s, FilePath d, boolean fingerprint, Ta
byte[] digest;
if (u != null) {
if (fingerprint) {
- digest = d.act(new CopyURLWithFingerprinting(u));
+ digest = d.act(new CopyURLWithFingerprinting(u, listener));
} else {
- d.copyFromRemotely(u);
+ new RobustHTTPClient().copyFromRemotely(d, u, listener);
digest = null;
}
} else {
@@ -636,16 +638,21 @@ private static String copyOne(VirtualFile s, FilePath d, boolean fingerprint, Ta
private static class CopyURLWithFingerprinting extends MasterToSlaveFileCallable {
private static final long serialVersionUID = 1;
private final URL u;
- CopyURLWithFingerprinting(URL u) {
+ private final TaskListener listener;
+ private final RobustHTTPClient client = new RobustHTTPClient();
+ CopyURLWithFingerprinting(URL u, TaskListener listener) {
this.u = u;
+ this.listener = listener;
}
@Override
public byte[] invoke(File f, VirtualChannel channel) throws IOException, InterruptedException {
hudson.util.IOUtils.mkdirs(f.getParentFile());
MessageDigest md5 = md5();
- try (InputStream is = u.openStream(); OutputStream os = new FileOutputStream(f)) {
- IOUtils.copy(is, new DigestOutputStream(os, md5));
- }
+ client.connect("download", "download " + RobustHTTPClient.sanitize(u) + " to " + f, c -> c.execute(new HttpGet(u.toString())), response -> {
+ try (InputStream is = response.getEntity().getContent(); OutputStream os = new FileOutputStream(f)) {
+ IOUtils.copy(is, new DigestOutputStream(os, md5));
+ }
+ }, listener);
return md5.digest();
}
}
diff --git a/src/test/java/hudson/plugins/copyartifact/CopyArtifactTest.java b/src/test/java/hudson/plugins/copyartifact/CopyArtifactTest.java
index a2d805eb..765b323b 100644
--- a/src/test/java/hudson/plugins/copyartifact/CopyArtifactTest.java
+++ b/src/test/java/hudson/plugins/copyartifact/CopyArtifactTest.java
@@ -102,12 +102,18 @@
import static org.junit.Assert.*;
import static org.junit.Assume.*;
+import org.junit.ClassRule;
+import org.jvnet.hudson.test.BuildWatcher;
/**
* Test interaction of copyartifact plugin with Jenkins core.
* @author Alan Harder
*/
public class CopyArtifactTest {
+
+ @ClassRule
+ public static BuildWatcher watcher = new BuildWatcher();
+
@Rule
public final JenkinsRule rule = new JenkinsRule();