From a254f202f971497a277f758cae5de84292073a4d Mon Sep 17 00:00:00 2001 From: Olivier Lamy Date: Sat, 6 Aug 2011 13:47:37 +0200 Subject: [PATCH] reset altSettings to null as was modified and cleanup tmp files --- .../java/hudson/maven/MavenModuleSetBuild.java | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) diff --git a/maven-plugin/src/main/java/hudson/maven/MavenModuleSetBuild.java b/maven-plugin/src/main/java/hudson/maven/MavenModuleSetBuild.java index ced7bd28deda..6e180b8ab316 100644 --- a/maven-plugin/src/main/java/hudson/maven/MavenModuleSetBuild.java +++ b/maven-plugin/src/main/java/hudson/maven/MavenModuleSetBuild.java @@ -561,6 +561,7 @@ protected Result doRun(final BuildListener listener) throws Exception { PrintStream logger = listener.getLogger(); Result r = null; File tmpSettingsFile = null; + FilePath remoteSettings = null; try { EnvVars envVars = getEnvironment(listener); @@ -628,12 +629,10 @@ protected Result doRun(final BuildListener listener) throws Exception { String settingsContent = config.content; if (settingsContent != null ) { tmpSettingsFile = File.createTempFile( "maven-settings", "xml" ); - FilePath target = new FilePath(getWorkspace(), tmpSettingsFile.getName()); + remoteSettings = new FilePath(getWorkspace(), tmpSettingsFile.getName()); ByteArrayInputStream bs = new ByteArrayInputStream(settingsContent.getBytes()); - target.copyFrom(bs); - // FIXME don't store that here as it's saved for next build !! - // FIXME ensure we delete this file in the workspace - project.setAlternateSettings( target.getRemote() ); + remoteSettings.copyFrom(bs); + project.setAlternateSettings( remoteSettings.getRemote() ); } } } @@ -814,7 +813,16 @@ protected Result doRun(final BuildListener listener) throws Exception { logger.println("project.getRootModule()="+project.getRootModule()); throw e; } finally { + if (project.getSettingConfigId() != null) { + // restore to null if as was modified + project.setAlternateSettings( null ); + project.save(); + } + // delete tmp files used for MavenSettingsProvider FileUtils.deleteQuietly( tmpSettingsFile ); + if (remoteSettings != null) { + remoteSettings.delete(); + } } }