Skip to content

Commit

Permalink
[JENKINS-34789] Release builds should not trigger downstream projects
Browse files Browse the repository at this point in the history
  • Loading branch information
fbelzunc committed Jun 6, 2016
1 parent 85f187c commit 40d36bf
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 0 deletions.
9 changes: 9 additions & 0 deletions src/main/java/hudson/maven/AbstractMavenProject.java
Expand Up @@ -74,6 +74,11 @@ public boolean shouldTriggerBuild(AbstractBuild build,

boolean ignoreUnsuccessfulUpstreams = ignoreUnsuccessfulUpstreams(downstreamProject);

MavenModuleSetBuild mavenModuleSetBuild = null;
if (build instanceof MavenModuleSetBuild) {
mavenModuleSetBuild = (MavenModuleSetBuild)build;
}

// if the downstream module depends on multiple modules,
// only trigger them when all the upstream dependencies are updated.

Expand All @@ -82,6 +87,10 @@ public boolean shouldTriggerBuild(AbstractBuild build,
if (areUpstreamsBuilding(downstreamProject, parent, listener)) {
return false;
}
// Check to see if is a release so we don't trigger the downstream project
else if (mavenModuleSetBuild != null && mavenModuleSetBuild.isARelease()) {
return false;
}
// Check to see if any of its upstream dependencies are in this list of downstream projects.
else if (inDownstreamProjects(downstreamProject)) {
listener.getLogger().println("Not triggering " + ModelHyperlinkNote.encodeTo(downstreamProject) + " because it has dependencies in the downstream project list");
Expand Down
17 changes: 17 additions & 0 deletions src/main/java/hudson/maven/MavenModuleSetBuild.java
Expand Up @@ -1438,6 +1438,23 @@ private String getRootPath(String prefix) {

private static final long serialVersionUID = 1L;
}

/**
* Check if the current build is a release or not.
* If all its maven modules are not SNAPSHOT then it is a release
*
* @since 2.12.2
* @return true if {@link MavenModuleSetBuild} is a release
*/
protected Boolean isARelease() {
MavenModuleSet mavenModuleSet = this.getProject();
for (MavenModule mavenModule : mavenModuleSet.getModules()) {
if(mavenModule.getVersion().contains("-SNAPSHOT")) {
return false;
}
}
return true;
}

private static final Logger LOGGER = Logger.getLogger(MavenModuleSetBuild.class.getName());

Expand Down

0 comments on commit 40d36bf

Please sign in to comment.