Skip to content
Permalink
Browse files

Testing JENKINS-31931.

Also fixing a buglet with nonexistent workspaces.
  • Loading branch information
jglick committed Aug 29, 2016
1 parent 86af7fd commit be563c856a50995271be490911988be0996865c4
@@ -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>
@@ -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>
@@ -39,6 +39,7 @@

@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;
@@ -65,6 +65,7 @@
@StepContextParameter private transient TaskListener listener;

@Override protected Void run() throws Exception {
workspace.mkdirs();
step.delegate.perform(run, workspace, launcher, listener);
return null;
}
@@ -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;
@@ -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
*/
@@ -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(
@@ -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;

@@ -68,6 +69,26 @@
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)) {

0 comments on commit be563c8

Please sign in to comment.
You can’t perform that action at this time.