Skip to content
Browse files

[JENKINS-21014] include verify in upstream candidate calculation

  • Loading branch information...
christiangalsterer committed Dec 21, 2013
1 parent 606dd38 commit f8d2b8499231b13be418d96907d3d52dc3951954
@@ -639,17 +639,21 @@ private int getDependencyRelevancy() {

for (String goal : Util.tokenize(getGoals())) {
if ("deploy".equals(goal) || "deploy:deploy".equals(goal)) {
return 2;
return 3;

if ("install".equals(goal)) {
relevancy = 2;

if ("verify".equals(goal)) {
relevancy = 1;

for (Publisher publisher : getParent().getPublishers()) {
if (publisher instanceof RedeployPublisher) {
return 2;
return 3;

@@ -1,8 +1,15 @@
package hudson.maven;

import static org.junit.Assert.assertThat;
import static org.hamcrest.CoreMatchers.hasItems;

import hudson.model.AbstractProject;
import org.jvnet.hudson.test.ExtractResourceSCM;
import org.jvnet.hudson.test.HudsonTestCase;

import java.util.ArrayList;
import java.util.List;

* Tests that Maven jobs are triggered, when snapshot dependencies of them were build.
@@ -72,4 +79,56 @@ public void testMixedTransitiveSnapshotTrigger() throws Exception {
assertEquals("Expected most recent build of second project to be #2", 2, projB.getLastBuild().getNumber());
assertEquals("Expected most recent build of third project to be #2", 2, projC.getLastBuild().getNumber());

* Verifies SNAPSHOT dependency resolution of multiple SNAPSHOT upstream dependencies. (JENKINS-21014)
* Note - has to build the projects once each first in order to get dependency info.
* Artifact C depends on artifacts A and B.
* For artifact A there exists two projects. Project A1 has install and A1 has verify in its maven goal. A1 is selected as upstream build for artifact C due to higher ranking of install over verify.
* For artifact B there exists two projects. Projects B1 has compile and B2 has verify in its maven goal. B2 is preferred as upstream dependency for artifact B as the verify goal takes precedence over the name tiebreaker which would prefer project B1.
public void testMultipleDependencySnapshotTrigger() throws Exception {

MavenModuleSet projA1 = createMavenProject("snap-dep-test-A1");
projA1.setGoals("clean install");
projA1.setScm(new ExtractResourceSCM(getClass().getResource("")));

MavenModuleSet projA2 = createMavenProject("snap-dep-test-A2");
projA2.setGoals("clean verify");
projA2.setScm(new ExtractResourceSCM(getClass().getResource("")));

MavenModuleSet projB1 = createMavenProject("snap-dep-test-B1");
projB1.setGoals("clean compile");
projB1.setScm(new ExtractResourceSCM(getClass().getResource("")));

MavenModuleSet projB2 = createMavenProject("snap-dep-test-B2");
projB2.setGoals("clean verify");
projB2.setScm(new ExtractResourceSCM(getClass().getResource("")));

MavenModuleSet projC = createMavenProject("snap-dep-test-C");
projC.setGoals("clean compile");
projC.setScm(new ExtractResourceSCM(getClass().getResource("")));

// Run all project at least once so that artifacts are known by Jenkins and SNAPSHOT dependencies are determined

final List<String> upstreamProjectNames = new ArrayList<String>();
for (AbstractProject project : projC.getUpstreamProjects()) {

assertEquals("Expected number of upstream project for project 'snap-dep-test-down' to be #2", 2, upstreamProjectNames.size());
assertThat("Expected 'snap-dep-test-A1' and 'snap-dep-test-B2' as upstream project for project 'snap-dep-test-C'", upstreamProjectNames, hasItems("snap-dep-test-A1", "snap-dep-test-B2"));

0 comments on commit f8d2b84

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