Skip to content

Commit

Permalink
[JENKINS-14653] Added a test to reproduce JENKINS-14653. TriggeredBui…
Browse files Browse the repository at this point in the history
…ldSelector cannot handle maven modules as upstreams.
  • Loading branch information
ikedam committed Oct 2, 2014
1 parent a7ce03c commit 0bf22b2
Showing 1 changed file with 48 additions and 0 deletions.
Expand Up @@ -25,7 +25,11 @@
package hudson.plugins.copyartifact;

import static org.junit.Assert.*;

import java.util.Arrays;

import hudson.Util;
import hudson.maven.MavenModuleSet;
import hudson.model.Cause;
import hudson.model.FreeStyleProject;
import hudson.model.ParametersAction;
Expand All @@ -38,6 +42,8 @@

import org.junit.Rule;
import org.junit.Test;
import org.jvnet.hudson.test.Bug;
import org.jvnet.hudson.test.ExtractResourceSCM;
import org.jvnet.hudson.test.JenkinsRule;
import org.jvnet.hudson.test.JenkinsRule.WebClient;

Expand Down Expand Up @@ -611,4 +617,46 @@ public void testIsUseNewest() throws Exception {
d.setGlobalUpstreamFilterStrategy(TriggeredBuildSelector.UpstreamFilterStrategy.UseNewest);
assertFalse(new TriggeredBuildSelector(false, TriggeredBuildSelector.UpstreamFilterStrategy.UseOldest).isUseNewest());
}

@Bug(14653)
@Test
public void testMavenModule() throws Exception {
j.configureDefaultMaven();
MavenModuleSet upstream = j.createMavenProject();
FreeStyleProject downstream = j.createFreeStyleProject();

upstream.setGoals("clean package");
upstream.setScm(new ExtractResourceSCM(getClass().getResource("maven-job.zip")));
upstream.getPublishersList().add(new BuildTrigger(downstream.getName(), Result.SUCCESS));

downstream.getBuildersList().add(new CopyArtifact(
String.format("%s/org.jvnet.hudson.main.test.multimod$moduleB", upstream.getName()),
"",
new TriggeredBuildSelector(false, null),
"**/*",
"",
"",
false,
false,
false
));

upstream.save();
downstream.save();
j.jenkins.rebuildDependencyGraph();

j.assertBuildStatusSuccess(upstream.scheduleBuild2(0));
j.waitUntilNoActivity();

FreeStyleBuild b = downstream.getLastBuild();
j.assertBuildStatusSuccess(b);

assertTrue(
String.format(
"File not found: files are: %s",
Arrays.asList(b.getWorkspace().list("**/*"))
),
b.getWorkspace().child("org.jvnet.hudson.main.test.multimod/moduleB/1.0-SNAPSHOT/moduleB-1.0-SNAPSHOT.jar").exists()
);
}
}

0 comments on commit 0bf22b2

Please sign in to comment.