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
  • Loading branch information
ndeloof committed Sep 11, 2012
1 parent 904041d commit 51d5220
Showing 1 changed file with 12 additions and 16 deletions.
28 changes: 12 additions & 16 deletions maven-plugin/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

2 comments on commit 51d5220

@olamy
Copy link
Member

@olamy olamy commented on 51d5220 Oct 9, 2012

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@ndeloof
Copy link
Contributor Author

@ndeloof ndeloof commented on 51d5220 Oct 9, 2012

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't understand why this regression happens, as hudson.maven.MavenUtil#createEmbedder set GlobalSettingsFile to MavenHome/conf/settings.xml if not set explicitly, so should have the exact same effect on mavenEmbedded - or maybe I miss something. reverting anyway

Please sign in to comment.