Skip to content

Commit

Permalink
Testing JENKINS-31931.
Browse files Browse the repository at this point in the history
Also fixing a buglet with nonexistent workspaces.
  • Loading branch information
jglick committed Aug 29, 2016
1 parent 86af7fd commit be563c8
Show file tree
Hide file tree
Showing 5 changed files with 36 additions and 6 deletions.
8 changes: 4 additions & 4 deletions pom.xml
Expand Up @@ -28,8 +28,8 @@
<parent>
<groupId>org.jenkins-ci.plugins</groupId>
<artifactId>plugin</artifactId>
<version>2.5</version>
<relativePath />
<version>2.14</version>
<relativePath/>
</parent>
<groupId>org.jenkins-ci.plugins.workflow</groupId>
<artifactId>workflow-basic-steps</artifactId>
Expand All @@ -52,13 +52,13 @@
<repositories>
<repository>
<id>repo.jenkins-ci.org</id>
<url>http://repo.jenkins-ci.org/public/</url>
<url>https://repo.jenkins-ci.org/public/</url>
</repository>
</repositories>
<pluginRepositories>
<pluginRepository>
<id>repo.jenkins-ci.org</id>
<url>http://repo.jenkins-ci.org/public/</url>
<url>https://repo.jenkins-ci.org/public/</url>
</pluginRepository>
</pluginRepositories>
<properties>
Expand Down
Expand Up @@ -39,6 +39,7 @@ public class ArtifactArchiverStepExecution extends AbstractSynchronousNonBlockin

@Override
protected Void run() throws Exception {
ws.mkdirs();
Map<String,String> files = ws.act(new ListFiles(step.getIncludes(), step.getExcludes()));
build.pickArtifactManager().archive(ws, launcher, new BuildListenerAdapter(listener), files);
return null;
Expand Down
Expand Up @@ -65,6 +65,7 @@ private static final class Execution extends AbstractSynchronousNonBlockingStepE
@StepContextParameter private transient TaskListener listener;

@Override protected Void run() throws Exception {
workspace.mkdirs();
step.delegate.perform(run, workspace, launcher, listener);
return null;
}
Expand Down
@@ -1,5 +1,6 @@
package org.jenkinsci.plugins.workflow.steps;

import java.util.Arrays;
import jenkins.util.VirtualFile;
import org.apache.commons.io.IOUtils;
import org.apache.commons.lang.StringUtils;
Expand All @@ -9,10 +10,9 @@
import org.junit.Assert;
import org.junit.Rule;
import org.junit.Test;
import org.jvnet.hudson.test.Issue;
import org.jvnet.hudson.test.JenkinsRule;

import java.util.Arrays;

/**
* @author Kohsuke Kawaguchi
*/
Expand Down Expand Up @@ -43,6 +43,13 @@ public void archive() throws Exception {
assertEquals("hello world", IOUtils.toString(archivedFile.open()));
}

@Issue("JENKINS-31931")
@Test public void nonexistent() throws Exception {
WorkflowJob p = j.jenkins.createProject(WorkflowJob.class, "p");
p.setDefinition(new CpsFlowDefinition("node {archive 'nonexistent/'}", true));
j.assertBuildStatusSuccess(p.scheduleBuild2(0));
}

@Test public void unarchiveDir() throws Exception {
WorkflowJob p = j.jenkins.createProject(WorkflowJob.class, "p");
p.setDefinition(new CpsFlowDefinition(StringUtils.join(Arrays.asList(
Expand Down
Expand Up @@ -43,6 +43,7 @@
import org.junit.ClassRule;
import org.junit.Rule;
import org.jvnet.hudson.test.BuildWatcher;
import org.jvnet.hudson.test.Issue;
import org.jvnet.hudson.test.JenkinsRule;
import org.jvnet.mock_javamail.Mailbox;

Expand All @@ -68,6 +69,26 @@ public class CoreStepTest {
assertEquals("[x.txt]", fa.getRecords().keySet().toString());
}

@Issue("JENKINS-31931")
@Test public void artifactArchiverNonexistent() throws Exception {
WorkflowJob p = r.jenkins.createProject(WorkflowJob.class, "p");
if (ArtifactArchiver.DescriptorImpl.class.isAnnotationPresent(Symbol.class)) {
p.setDefinition(new CpsFlowDefinition("node {archiveArtifacts artifacts: 'nonexistent/', allowEmptyArchive: true}", true));
} else { // TODO 2.x delete
p.setDefinition(new CpsFlowDefinition("node {step([$class: 'ArtifactArchiver', artifacts: 'nonexistent/', allowEmptyArchive: true])}", true));
}
WorkflowRun b = r.assertBuildStatusSuccess(p.scheduleBuild2(0));
if (ArtifactArchiver.DescriptorImpl.class.isAnnotationPresent(Symbol.class)) {
p.setDefinition(new CpsFlowDefinition("node {archiveArtifacts 'nonexistent/'}", true));
} else { // TODO 2.x delete
p.setDefinition(new CpsFlowDefinition("node {step([$class: 'ArtifactArchiver', artifacts: 'nonexistent/'])}", true));
}
b = r.assertBuildStatus(Result.FAILURE, p.scheduleBuild2(0));
/* TODO bug in ArtifactArchiver:
r.assertLogContains(hudson.tasks.Messages.ArtifactArchiver_NoMatchFound("nonexistent/"), b);
*/
}

@Test public void fingerprinter() throws Exception {
WorkflowJob p = r.jenkins.createProject(WorkflowJob.class, "p");
if (Fingerprinter.DescriptorImpl.class.isAnnotationPresent(Symbol.class)) {
Expand Down

0 comments on commit be563c8

Please sign in to comment.