mirror of
https://github.com/jenkinsci/jenkins.git
synced 2026-11-16 05:22:22 +00:00
[FIXED JENKINS-7684] NullPointerException when an incremental build is triggered
This commit is contained in:
1 parent
c1739b8d71
commit
a19afb186b
1 file changed
+18
-9
@@ -206,7 +206,7 @@ public class MavenModuleSetBuild extends AbstractMavenBuild<MavenModuleSet,Maven
|
||||
|
||||
private boolean belongsToSubsidiary(List<MavenModule> subsidiaries, String path) {
|
||||
for (MavenModule sub : subsidiaries)
|
||||
if (FilenameUtils.separatorsToUnix(path).startsWith(FilenameUtils.normalize(sub.getRelativePath())))
|
||||
if (FilenameUtils.separatorsToUnix(path).startsWith(normalizePath(sub.getRelativePath())))
|
||||
return true;
|
||||
return false;
|
||||
}
|
||||
@@ -216,7 +216,7 @@ public class MavenModuleSetBuild extends AbstractMavenBuild<MavenModuleSet,Maven
|
||||
*/
|
||||
private boolean isDescendantOf(ChangeLogSet.Entry e, MavenModule mod) {
|
||||
for (String path : e.getAffectedPaths()) {
|
||||
if (FilenameUtils.separatorsToUnix(path).startsWith(FilenameUtils.normalize(mod.getRelativePath())))
|
||||
if (FilenameUtils.separatorsToUnix(path).startsWith(normalizePath(mod.getRelativePath())))
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
@@ -281,7 +281,7 @@ public class MavenModuleSetBuild extends AbstractMavenBuild<MavenModuleSet,Maven
|
||||
|
||||
return result != 0 ? result : -1;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Estimates the duration overhead the {@link MavenModuleSetBuild} itself adds
|
||||
* to the sum of duration of the module builds.
|
||||
@@ -309,6 +309,18 @@ public class MavenModuleSetBuild extends AbstractMavenBuild<MavenModuleSet,Maven
|
||||
return Math.round((double)overhead / moduleSetBuilds.size());
|
||||
}
|
||||
|
||||
private static String normalizePath(String relPath) {
|
||||
// JENKINS-8525 FilenameUtils.normalize for ../foo returns null
|
||||
if (StringUtils.isEmpty(relPath) || StringUtils.startsWith( relPath, "../" )) {
|
||||
LOGGER.config("No need to normalize " + (StringUtils.isEmpty(relPath) ? "an empty path" : relPath));
|
||||
} else {
|
||||
String tmp = FilenameUtils.normalize( relPath );
|
||||
LOGGER.config("Normalized path " + relPath + " to "+tmp);
|
||||
relPath = tmp;
|
||||
}
|
||||
return relPath;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the version of Maven used for build.
|
||||
*
|
||||
@@ -492,7 +504,7 @@ public class MavenModuleSetBuild extends AbstractMavenBuild<MavenModuleSet,Maven
|
||||
"Either your server has no Maven installations defined, or the requested Maven version does not exist.");
|
||||
|
||||
mvn = mvn.forEnvironment(envVars).forNode(Computer.currentComputer().getNode(), listener);
|
||||
|
||||
|
||||
MavenInformation mavenInformation = getModuleRoot().act( new MavenVersionCallable( mvn.getHome() ));
|
||||
|
||||
String mavenVersion = mavenInformation.getVersion();
|
||||
@@ -1209,11 +1221,8 @@ public class MavenModuleSetBuild extends AbstractMavenBuild<MavenModuleSet,Maven
|
||||
private void toPomInfo(MavenProject mp, PomInfo parent, Map<String,MavenProject> abslPath, Set<PomInfo> infos) throws IOException {
|
||||
|
||||
String relPath = PathTool.getRelativeFilePath( this.moduleRootPath, mp.getBasedir().getPath() );
|
||||
|
||||
// JENKINS-8525 FilenameUtils.normalize for ../foo returns null
|
||||
if (!StringUtils.startsWith( relPath, "../" )) {
|
||||
relPath = FilenameUtils.normalize( relPath );
|
||||
}
|
||||
relPath = normalizePath(relPath);
|
||||
|
||||
if (parent == null ) {
|
||||
relPath = getRootPath(rootPOMRelPrefix);
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user