Skip to content

Commit

Permalink
[JENKINS-9084] setting maven home is enough for global settings to be…
Browse files Browse the repository at this point in the history
… m.getHome()/conf/settings.xml

@see hudson.maven.MavenUtil#createEmbedder
Originally-Committed-As: 51d5220f6c19c4e7d5c35a07b62219472b2a7870
  • Loading branch information
ndeloof committed Sep 11, 2012
1 parent 7921ffd commit d7527cb
Showing 1 changed file with 12 additions and 16 deletions.
28 changes: 12 additions & 16 deletions src/main/java/hudson/maven/RedeployPublisher.java
Expand Up @@ -209,7 +209,7 @@ private MavenEmbedder createEmbedder(TaskListener listener, AbstractBuild<?,?> b
String privateRepository = null;
FilePath remoteSettingsFromConfig = null;

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

Expand Down Expand Up @@ -269,29 +269,25 @@ private MavenEmbedder createEmbedder(TaskListener listener, AbstractBuild<?,?> b
// assume that build was made on master
buildNode = Jenkins.getInstance();
}
m = mavenModuleSet.getMaven().forNode(buildNode, listener);

if (StringUtils.isBlank( altSettingsPath ) ) {
// get userHome from the node where job has been executed
String remoteUserHome = build.getWorkspace().act( new GetUserHome() );
altSettingsPath = remoteUserHome + "/.m2/settings.xml";
}

// we copy this file in the master in a temporary file
FilePath filePath = new FilePath( tmpSettings );

// we copy this file in the master in a temporary file
FilePath remoteSettings = build.getWorkspace().child( altSettingsPath );
if (!remoteSettings.exists()) {
// JENKINS-9084 we finally use $M2_HOME/conf/settings.xml as maven do

String mavenHome =
((MavenModuleSet) project).getMaven().forNode(buildNode, listener ).getHome();
String settingsPath = mavenHome + "/conf/settings.xml";
remoteSettings = build.getWorkspace().child( settingsPath);
if (remoteSettings != null) {
listener.getLogger().println( "Maven RedeployPublisher use " + (buildNode != null ? buildNode.getNodeName() : "local" )
+ " maven settings from : " + remoteSettings.getRemote() );
tmpSettings = File.createTempFile( "jenkins", "temp-settings.xml" );
FilePath filePath = new FilePath( tmpSettings );
remoteSettings.copyTo( filePath );
settingsLoc = tmpSettings;
}
listener.getLogger().println( "Maven RedeployPublisher use remote " + (buildNode != null ? buildNode.getNodeName() : "local" )
+ " maven settings from : " + remoteSettings.getRemote() );
remoteSettings.copyTo( filePath );
settingsLoc = tmpSettings;


}

MavenEmbedderRequest mavenEmbedderRequest = new MavenEmbedderRequest(listener,
Expand Down

0 comments on commit d7527cb

Please sign in to comment.