Skip to content
Merged
Show file tree
Hide file tree
Changes from 25 commits
Commits
Show all changes
26 commits
Select commit Hold shift + click to select a range
5fb3d84
[JENKINS-49635] Support new VirtualFile.asRemotable API.
jglick Feb 28, 2018
7562986
Stash support.
jglick Mar 13, 2018
6ba60da
Updates.
jglick Mar 14, 2018
75b73bf
CI failure.
jglick Mar 14, 2018
a2abb37
useBeta
jglick Mar 26, 2018
781d409
Calling VirtualFile.toExternalURL rather than asRemotable.
jglick Apr 2, 2018
d323514
Picking up https://github.com/jenkinsci/plugin-pom/pull/98.
jglick Apr 3, 2018
b3a8a3c
Merge branch 'master' into VirtualFile-JENKINS-49635
jglick Apr 16, 2018
a01cdb6
Updated.
jglick Apr 16, 2018
c072ff8
Merge branch 'master' into VirtualFile-JENKINS-49635
jglick Apr 17, 2018
f44835b
requireUpperBoundDeps
jglick Apr 17, 2018
3959063
Merge branch 'master' into VirtualFile-JENKINS-49635
jglick Apr 23, 2018
d19b231
jenkins.version=2.118
jglick Apr 23, 2018
ce7a8ac
Consuming incrementals.
jglick Apr 27, 2018
2170267
Preparing to produce Incrementals.
jglick Apr 27, 2018
d2bd052
Linking also to https://github.com/jenkinsci/workflow-step-api-plugin…
jglick Apr 27, 2018
c9d28b0
Picking up https://github.com/jenkinsci/plugin-pom/pull/105.
jglick May 9, 2018
af6af8d
[JENKINS-51187] Moving git-changelist-maven-extension into incrementa…
jglick May 10, 2018
f9f8b16
Updates.
jglick May 11, 2018
c660832
Updated.
jglick May 16, 2018
eed2d6f
workflow-step-api-plugin.version=2.15
jglick May 21, 2018
ae43469
Using RobustHTTPClient utility for artifact downloads.
jglick Jun 5, 2018
5d47212
apache-httpcomponents-client-4-api 4.5.5-3.0
jglick Jun 13, 2018
d5baf3a
https://github.com/jenkinsci/workflow-api-plugin/pull/67 released.
jglick Jun 15, 2018
2e4d5d0
May as well use LTS also.
jglick Jun 15, 2018
5882dbd
Merge branch 'master' into VirtualFile-JENKINS-49635
svanoort Jun 15, 2018
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions .mvn/extensions.xml
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>
2 changes: 2 additions & 0 deletions .mvn/maven.config
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
-Pconsume-incrementals
-Pmight-produce-incrementals
2 changes: 1 addition & 1 deletion Jenkinsfile
Original file line number Diff line number Diff line change
@@ -1 +1 @@
buildPlugin(jenkinsVersions: [null, '2.32.3'])
buildPlugin()
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

2.107.1 please

Copy link
Member Author

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.

38 changes: 24 additions & 14 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -28,12 +28,12 @@
<parent>
<groupId>org.jenkins-ci.plugins</groupId>
<artifactId>plugin</artifactId>
<version>3.2</version>
<version>3.15</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>
Expand All @@ -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>
Expand All @@ -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.1</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</workflow-api-plugin.version>
<useBeta>true</useBeta>
</properties>
<dependencies>
<dependency>
Expand All @@ -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-3.0</version>
</dependency>
<dependency>
<groupId>org.jenkins-ci.plugins.workflow</groupId>
Expand Down Expand Up @@ -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
Expand Up @@ -4,6 +4,7 @@
import hudson.Extension;
import hudson.FilePath;
import hudson.model.Run;
import hudson.model.TaskListener;
import org.kohsuke.stapler.DataBoundConstructor;
import org.kohsuke.stapler.DataBoundSetter;

Expand Down Expand Up @@ -45,7 +46,7 @@ public String getDisplayName() {
}

@Override public Set<? extends Class<?>> getRequiredContext() {
return ImmutableSet.of(FilePath.class, Run.class);
return ImmutableSet.of(FilePath.class, Run.class, TaskListener.class);
}

}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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.")
Expand All @@ -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();

Expand All @@ -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);
Copy link
Member

Choose a reason for hiding this comment

The 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;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,10 @@
package org.jenkinsci.plugins.workflow.support.steps.stash;

import com.google.common.collect.ImmutableSet;
import hudson.EnvVars;
import hudson.Extension;
import hudson.FilePath;
import hudson.Launcher;
import hudson.Util;
import hudson.model.Run;
import hudson.model.TaskListener;
Expand Down Expand Up @@ -110,7 +112,7 @@ public static class Execution extends SynchronousNonBlockingStepExecution<Void>
}

@Override protected Void run() throws Exception {
StashManager.stash(getContext().get(Run.class), step.name, getContext().get(FilePath.class), getContext().get(TaskListener.class), step.includes, step.excludes,
StashManager.stash(getContext().get(Run.class), step.name, getContext().get(FilePath.class), getContext().get(Launcher.class), getContext().get(EnvVars.class), getContext().get(TaskListener.class), step.includes, step.excludes,
step.useDefaultExcludes, step.allowEmpty);
return null;
}
Expand All @@ -128,7 +130,7 @@ public static class Execution extends SynchronousNonBlockingStepExecution<Void>
}

@Override public Set<? extends Class<?>> getRequiredContext() {
return ImmutableSet.of(Run.class, FilePath.class, TaskListener.class);
return ImmutableSet.of(Run.class, FilePath.class, Launcher.class, EnvVars.class, TaskListener.class);
}

@Override public String argumentsToString(Map<String, Object> namedArgs) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,10 @@

import com.google.common.collect.ImmutableSet;
import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
import hudson.EnvVars;
import hudson.Extension;
import hudson.FilePath;
import hudson.Launcher;
import hudson.model.Run;
import hudson.model.TaskListener;
import java.util.Set;
Expand Down Expand Up @@ -71,7 +73,7 @@ public static class Execution extends SynchronousNonBlockingStepExecution<Void>
}

@Override protected Void run() throws Exception {
StashManager.unstash(getContext().get(Run.class), name, getContext().get(FilePath.class), getContext().get(TaskListener.class));
StashManager.unstash(getContext().get(Run.class), name, getContext().get(FilePath.class), getContext().get(Launcher.class), getContext().get(EnvVars.class), getContext().get(TaskListener.class));
return null;
}

Expand All @@ -88,7 +90,7 @@ public static class Execution extends SynchronousNonBlockingStepExecution<Void>
}

@Override public Set<? extends Class<?>> getRequiredContext() {
return ImmutableSet.of(Run.class, FilePath.class, TaskListener.class);
return ImmutableSet.of(Run.class, FilePath.class, Launcher.class, EnvVars.class, TaskListener.class);
}

}
Expand Down
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();
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What is this used for?

Copy link
Member Author

Choose a reason for hiding this comment

The 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();

/**
Expand Down Expand Up @@ -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));
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

no stash/unstash test?

Copy link
Member Author

Choose a reason for hiding this comment

The 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 ArtifactManagerFactory.

DirectArtifactManagerFactory.whileBlockingOpen(() -> {
j.assertLogContains("loaded contents", j.buildAndAssertSuccess(p));
return null;
});
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,6 @@
import hudson.model.Run;
import hudson.model.Slave;
import hudson.model.TaskListener;
import hudson.slaves.CommandLauncher;
import hudson.slaves.ComputerLauncher;
import hudson.slaves.NodeProperty;
import hudson.slaves.RetentionStrategy;
Expand Down