Maven jobs are using the root of the drive c as user home when the slave is launched as a windows service

Issue

When building a Maven job on a windows slave configured as service the user.home java system property is pointing to c:\ thus Maven is looking for user’s settings under c:\.m2\settings.xml, c:\.m2\security-settings.xml and it is storing the local repository in c:\.m2\repository\.

Environment

  • Jenkins
  • Jenkins LTS
  • CloudBees Jenkins Enterprise
  • Maven Job
  • Windows slave launched as service

Resolution

When a Jenkins slave is installed on windows as a service it configured to run as Local system account

Jenkins Slave Windows Service General

Jenkins Slave Windows Service Logon Local System Account

This isn’t a real account on the server, that’s why Maven defines the user’s home (user.home java system property) as c:\

If you reconfigure your service to be launch with a real account (Adminsitrator below)

Jenkins Slave Windows Service Logon Specific Account

Then Maven correctly defines the user’s home as C:\Users\Administrator

Note: To properly manage your Maven settings accross slaves it is recommended to use the Config File Provider Plugin which allows to centralize the management of these configuration files in your master and to automatically deploy them in your slaves to let Maven use them transparently.

Have more questions? Submit a request

0 Comments

Please sign in to leave a comment.