-
-
Notifications
You must be signed in to change notification settings - Fork 126
[JENKINS-49635] Support new VirtualFile.toExternalURL API #60
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 22 commits
5fb3d84
7562986
6ba60da
75b73bf
a2abb37
781d409
d323514
b3a8a3c
a01cdb6
c072ff8
f44835b
3959063
d19b231
ce7a8ac
2170267
d2bd052
c9d28b0
af6af8d
f9f8b16
c660832
eed2d6f
ae43469
5d47212
d5baf3a
2e4d5d0
5882dbd
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,7 @@ | ||
| <extensions xmlns="http://maven.apache.org/EXTENSIONS/1.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/EXTENSIONS/1.0.0 http://maven.apache.org/xsd/core-extensions-1.0.0.xsd"> | ||
| <extension> | ||
| <groupId>io.jenkins.tools.incrementals</groupId> | ||
| <artifactId>git-changelist-maven-extension</artifactId> | ||
| <version>1.0-beta-3</version> | ||
| </extension> | ||
| </extensions> |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,2 @@ | ||
| -Pconsume-incrementals | ||
| -Pmight-produce-incrementals |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1 +1 @@ | ||
| buildPlugin(jenkinsVersions: [null, '2.32.3']) | ||
| buildPlugin() | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -28,12 +28,12 @@ | |
| <parent> | ||
| <groupId>org.jenkins-ci.plugins</groupId> | ||
| <artifactId>plugin</artifactId> | ||
| <version>3.2</version> | ||
| <version>3.13</version> | ||
| <relativePath /> | ||
| </parent> | ||
| <groupId>org.jenkins-ci.plugins.workflow</groupId> | ||
| <artifactId>workflow-basic-steps</artifactId> | ||
| <version>2.8-SNAPSHOT</version> | ||
| <version>${revision}${changelist}</version> | ||
| <packaging>hpi</packaging> | ||
| <name>Pipeline: Basic Steps</name> | ||
| <url>https://wiki.jenkins-ci.org/display/JENKINS/Pipeline+Basic+Steps+Plugin</url> | ||
|
|
@@ -47,7 +47,7 @@ | |
| <connection>scm:git:git://github.com/jenkinsci/${project.artifactId}-plugin.git</connection> | ||
| <developerConnection>scm:git:[email protected]:jenkinsci/${project.artifactId}-plugin.git</developerConnection> | ||
| <url>https://github.com/jenkinsci/${project.artifactId}-plugin</url> | ||
| <tag>HEAD</tag> | ||
| <tag>${scmTag}</tag> | ||
| </scm> | ||
| <repositories> | ||
| <repository> | ||
|
|
@@ -62,11 +62,15 @@ | |
| </pluginRepository> | ||
| </pluginRepositories> | ||
| <properties> | ||
| <jenkins.version>2.7.3</jenkins.version> | ||
| <java.level>7</java.level> | ||
| <workflow-step-api-plugin.version>2.13</workflow-step-api-plugin.version> | ||
| <revision>2.8</revision> | ||
| <changelist>-SNAPSHOT</changelist> | ||
| <jenkins.version>2.121</jenkins.version> | ||
| <java.level>8</java.level> | ||
| <workflow-step-api-plugin.version>2.15</workflow-step-api-plugin.version> | ||
| <workflow-cps-plugin.version>2.32</workflow-cps-plugin.version> | ||
| <workflow-support-plugin.version>2.14</workflow-support-plugin.version> | ||
| <workflow-api-plugin.version>2.28-rc343.e9b9e0610374</workflow-api-plugin.version> <!-- TODO https://github.com/jenkinsci/workflow-api-plugin/pull/67 --> | ||
| <useBeta>true</useBeta> | ||
| </properties> | ||
| <dependencies> | ||
| <dependency> | ||
|
|
@@ -89,18 +93,17 @@ | |
| <dependency> | ||
| <groupId>org.jenkins-ci.plugins.workflow</groupId> | ||
| <artifactId>workflow-api</artifactId> | ||
| <version>2.16</version> | ||
| <exclusions> | ||
| <exclusion> | ||
| <groupId>org.jenkins-ci.plugins</groupId> | ||
| <artifactId>scm-api</artifactId> | ||
| </exclusion> | ||
| </exclusions> | ||
| <version>${workflow-api-plugin.version}</version> | ||
| </dependency> | ||
| <dependency> | ||
| <groupId>org.jenkins-ci.plugins</groupId> | ||
| <artifactId>structs</artifactId> | ||
| <version>1.6</version> | ||
| <version>1.14</version> | ||
| </dependency> | ||
| <dependency> | ||
| <groupId>org.jenkins-ci.plugins</groupId> | ||
| <artifactId>apache-httpcomponents-client-4-api</artifactId> | ||
| <version>4.5.5-2.2-rc32.4a9f3bcc3908</version> <!-- TODO https://github.com/jenkinsci/apache-httpcomponents-client-4-api-plugin/pull/9 --> | ||
| </dependency> | ||
| <dependency> | ||
| <groupId>org.jenkins-ci.plugins.workflow</groupId> | ||
|
|
@@ -194,5 +197,12 @@ | |
| <version>2.8</version> | ||
| <scope>test</scope> | ||
| </dependency> | ||
| <dependency> | ||
| <groupId>org.jenkins-ci.plugins.workflow</groupId> | ||
| <artifactId>workflow-api</artifactId> | ||
| <version>${workflow-api-plugin.version}</version> | ||
| <classifier>tests</classifier> | ||
| <scope>test</scope> | ||
| </dependency> | ||
| </dependencies> | ||
| </project> | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -4,19 +4,19 @@ | |
| import hudson.AbortException; | ||
| import hudson.FilePath; | ||
| import hudson.model.Run; | ||
| import hudson.model.TaskListener; | ||
| import io.jenkins.plugins.httpclient.RobustHTTPClient; | ||
| import jenkins.model.ArtifactManager; | ||
| import jenkins.util.VirtualFile; | ||
|
|
||
| import java.io.IOException; | ||
| import java.io.InputStream; | ||
| import java.net.URL; | ||
| import java.util.ArrayList; | ||
| import java.util.List; | ||
| import java.util.Map; | ||
| import java.util.Map.Entry; | ||
|
|
||
| /** | ||
| * @author Kohsuke Kawaguchi | ||
| */ | ||
| public class ArtifactUnarchiverStepExecution extends SynchronousNonBlockingStepExecution<List<FilePath>> { | ||
|
|
||
| @SuppressFBWarnings(value="SE_TRANSIENT_FIELD_NOT_RESTORED", justification="Only used when starting.") | ||
|
|
@@ -34,6 +34,7 @@ public class ArtifactUnarchiverStepExecution extends SynchronousNonBlockingStepE | |
| protected List<FilePath> run() throws Exception { | ||
| // where to copy artifacts from? | ||
| Run<?, ?> r = getContext().get(Run.class); // TODO consider an option to override this (but in what format?) | ||
| TaskListener listener = getContext().get(TaskListener.class); | ||
|
|
||
| ArtifactManager am = r.getArtifactManager(); | ||
|
|
||
|
|
@@ -50,21 +51,26 @@ protected List<FilePath> run() throws Exception { | |
| if (dst.isDirectory()) | ||
| dst = dst.child(getFileName(all[0])); | ||
|
|
||
| files.add(copy(am.root().child(all[0]), dst)); | ||
| files.add(copy(am.root().child(all[0]), dst, listener)); | ||
| } else { | ||
| // copy into a directory | ||
| for (String path : all) { | ||
| files.add(copy(am.root().child(path), dst.child(path))); | ||
| files.add(copy(am.root().child(path), dst.child(path), listener)); | ||
| } | ||
| } | ||
| } | ||
|
|
||
| return files; | ||
| } | ||
|
|
||
| private FilePath copy(VirtualFile src, FilePath dst) throws IOException, InterruptedException { | ||
| try (InputStream in = src.open()) { | ||
| dst.copyFrom(in); | ||
| private FilePath copy(VirtualFile src, FilePath dst, TaskListener listener) throws IOException, InterruptedException { | ||
| URL u = src.toExternalURL(); | ||
| if (u != null) { | ||
| new RobustHTTPClient().copyFromRemotely(dst, u, listener); | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Caveat that I need to look into what guarantees this is offering and how thread interruption is handled in the RobustHTTPClient |
||
| } else { | ||
| try (InputStream in = src.open()) { | ||
| dst.copyFrom(in); | ||
| } | ||
| } | ||
| return dst; | ||
| } | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,22 +1,26 @@ | ||
| package org.jenkinsci.plugins.workflow.steps; | ||
|
|
||
| import java.util.Arrays; | ||
| import jenkins.model.ArtifactManagerConfiguration; | ||
| import jenkins.util.VirtualFile; | ||
| import org.apache.commons.io.IOUtils; | ||
| import org.apache.commons.lang.StringUtils; | ||
| import org.jenkinsci.plugins.workflow.DirectArtifactManagerFactory; | ||
| import org.jenkinsci.plugins.workflow.cps.CpsFlowDefinition; | ||
| import org.jenkinsci.plugins.workflow.job.WorkflowJob; | ||
| import org.jenkinsci.plugins.workflow.job.WorkflowRun; | ||
| import org.junit.Assert; | ||
| import static org.junit.Assert.*; | ||
| import org.junit.ClassRule; | ||
| import org.junit.Rule; | ||
| import org.junit.Test; | ||
| import org.jvnet.hudson.test.BuildWatcher; | ||
| import org.jvnet.hudson.test.Issue; | ||
| import org.jvnet.hudson.test.JenkinsRule; | ||
|
|
||
| /** | ||
| * @author Kohsuke Kawaguchi | ||
| */ | ||
| public class ArtifactArchiverStepTest extends Assert { | ||
| public class ArtifactArchiverStepTest { | ||
|
|
||
| @ClassRule public static BuildWatcher watcher = new BuildWatcher(); | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. What is this used for?
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Just so that the test log includes the log from the build run at line 90. |
||
|
|
||
| @Rule public JenkinsRule j = new JenkinsRule(); | ||
|
|
||
| /** | ||
|
|
@@ -74,5 +78,18 @@ public void archive() throws Exception { | |
| j.assertLogContains("one/two", b); | ||
| } | ||
|
|
||
| } | ||
| @Issue("JENKINS-49635") | ||
| @Test | ||
| public void directDownload() throws Exception { | ||
| ArtifactManagerConfiguration.get().getArtifactManagerFactories().add(new DirectArtifactManagerFactory()); | ||
| j.createSlave("remote1", null, null); | ||
| j.createSlave("remote2", null, null); | ||
| WorkflowJob p = j.jenkins.createProject(WorkflowJob.class, "p"); | ||
| p.setDefinition(new CpsFlowDefinition("node('remote1') {writeFile file: 'x', text: 'contents'; archiveArtifacts 'x'}; node('remote2') {unarchive mapping: [x: 'x']; echo(/loaded ${readFile('x')}/)}", true)); | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. no
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. No, because that behavior is not being defined in this PR—it would be overridden in the plugin providing the |
||
| DirectArtifactManagerFactory.whileBlockingOpen(() -> { | ||
| j.assertLogContains("loaded contents", j.buildAndAssertSuccess(p)); | ||
| return null; | ||
| }); | ||
| } | ||
|
|
||
| } | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
2.107.1 please
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No, the baseline is newer than that.