Skip to content

Commit

Permalink
Download global settings.xml from node to master
Browse files Browse the repository at this point in the history
Add logic to copy back global settings.xml the same way
as local settings is already copied.
  • Loading branch information
tomasol authored and aheritier committed Oct 16, 2016
1 parent 0644d67 commit 01c60df
Showing 1 changed file with 16 additions and 4 deletions.
20 changes: 16 additions & 4 deletions src/main/java/hudson/maven/RedeployPublisher.java
Expand Up @@ -211,6 +211,7 @@ private MavenEmbedder createEmbedder(TaskListener listener, AbstractBuild<?,?> b
String privateRepository = null;

File tmpSettings = File.createTempFile( "jenkins", "temp-settings.xml" );
File tmpSettingsGlobal = File.createTempFile( "jenkins", "temp-global-settings.xml" );
try {
AbstractProject project = build.getProject();

Expand All @@ -236,10 +237,6 @@ private MavenEmbedder createEmbedder(TaskListener listener, AbstractBuild<?,?> b
// TODO check if the remoteSettings has a localRepository configured and disabled it

String altSettingsPath = SettingsProvider.getSettingsRemotePath(((MavenModuleSet) project).getSettings(), build, listener);
String remoteGlobalSettingsPath = GlobalSettingsProvider.getSettingsRemotePath(((MavenModuleSet) project).getGlobalSettings(), build, listener);
if(remoteGlobalSettingsPath != null){
remoteGlobalSettingsFromConfig = new File(remoteGlobalSettingsPath);
}

Node buildNode = build.getBuiltOn();

Expand Down Expand Up @@ -268,6 +265,18 @@ private MavenEmbedder createEmbedder(TaskListener listener, AbstractBuild<?,?> b
+ " maven settings from : " + remoteSettings.getRemote() );
remoteSettings.copyTo( filePath );
settingsLoc = tmpSettings;

String remoteGlobalSettingsPath = GlobalSettingsProvider.getSettingsRemotePath(((MavenModuleSet) project).getGlobalSettings(), build, listener);
if(remoteGlobalSettingsPath != null){
// copy global settings from slave's remoteGlobalSettingsPath to tmpSettingsGlobal
FilePath filePathGlobal = new FilePath( tmpSettingsGlobal );
FilePath remoteSettingsGlobal = build.getWorkspace().child( remoteGlobalSettingsPath );

listener.getLogger().println( "Maven RedeployPublisher use remote " + (buildNode != null ? buildNode.getNodeName() : "local" )
+ " maven global settings from : " + remoteSettingsGlobal.getRemote() );
remoteSettingsGlobal.copyTo( filePathGlobal );
remoteGlobalSettingsFromConfig = tmpSettingsGlobal;
}

}

Expand All @@ -289,6 +298,9 @@ private MavenEmbedder createEmbedder(TaskListener listener, AbstractBuild<?,?> b
if (tmpSettings != null) {
tmpSettings.delete();
}
if (tmpSettingsGlobal != null) {
tmpSettingsGlobal.delete();
}
}
}

Expand Down

0 comments on commit 01c60df

Please sign in to comment.