Currently the upstream candidate resolution mechanism for "Build whenever a SNAPSHOT dependency is built" only considers Maven install and deploy lifecycle when there is more than one possible upstream build for the same artifact. In this case the name tiebreaker kicks in, which then determines the upstream build comparing by the job name. This is a reproducible behaviour but doesn't cater for the following situation as then the "wrong" build is selected depending on your naming strategy.
If you want to split your job into two steps where the first step verifies that your maven project compiles and all test are successful and in the second step one then upload the new artefacts to your remote repository (if the first step works fine) this works fine if you run the first step with "mvn clean verify" and the second step with "mvn deploy" and there is no other upstream candidate. It doesn't work when there are other possible candidates (e.g. a static code analysis build of the same artefact) as then the tiebreaker kicks in and the the "wrong" build is selected (see above).
Artefact A has the following two builds
- A_1 (Static code analysis, which only compiles)
- A_2 (CI, step1: mvn clean verify, step2: mvn deploy)
Artifact B depends on artifact A
There should be an automatic upstream build from B to A_2 and not A_1.
With the current implementation, A_1 would be considered as upstream candidate as it is preferred by the name sorting tie breaker
In order to make the "Build whenever a SNAPSHOT dependency is built" feature working for the above situation the algorithm to determine the upstream build should not only consider the install and deploy lifecycle phase, but also the verify phase in preference over the name sorting tie breaker.