Bamboo runs a build with the wrong user
Asked by Nicolas_Grussenmeyer:

Hi,

We are experiencing a weird issue where bamboo is not using the same user to run the build in only one build plan.

We are running Bamboo as a service on a windows server 2012. In the bamboo service config it's specified to run it with the local user "bamboo".

It works fine for all our plans except one which is running the builds with "Administrator". In the end, the local .m2 used is the one from "Administrator" instead of the one from "bamboo" causing the artifact dependencies download to fail because no username/password are specified in settings.xml.

Here is the debug trace for the non working build :

build 07-Nov-2017 14:17:41 Apache Maven 3.0.5 (r01de14724cdef164cd33c7c8c2fe155faf9602da; 2013-02-19 13:51:28+0000)  
build 07-Nov-2017 14:17:41 Maven home: D:\\Data\\Bamboo\\tools\\Maven_3.0.5  
build 07-Nov-2017 14:17:41 Java version: 1.6.0_45, vendor: Sun Microsystems Inc.  
build 07-Nov-2017 14:17:41 Java home: D:\\Program Files\\Java\\jdk1.6.0_45\\jre  
build 07-Nov-2017 14:17:41 Default locale: en_US, platform encoding: Cp1252  
build 07-Nov-2017 14:17:41 OS name: "windows server 2012", version: "6.2", arch: "amd64", family: "windows"  
build 07-Nov-2017 14:17:42 \[INFO\] Error stacktraces are turned on.  
build 07-Nov-2017 14:17:42 \[DEBUG\] Reading global settings from D:\\Data\\Bamboo\\tools\\Maven_3.0.5\\conf\\settings.xml  
build 07-Nov-2017 14:17:42 \[DEBUG\] Reading user settings from C:\\Users\\Administrator\\.m2\\settings.xml  
build 07-Nov-2017 14:17:42 \[DEBUG\] Using local repository at C:\\Users\\Administrator\\.m2\\repository  
build 07-Nov-2017 14:17:42 \[DEBUG\] Using manager EnhancedLocalRepositoryManager with priority 10 for C:\\Users\\Administrator\\.m2\\repository  
build 07-Nov-2017 14:17:42 \[INFO\] Scanning for projects...

Here is the debug trace for the working build :

build 07-Nov-2017 13:48:26 Apache Maven 3.0.5 (r01de14724cdef164cd33c7c8c2fe155faf9602da; 2013-02-19 13:51:28+0000)  
build 07-Nov-2017 13:48:26 Maven home: D:\\Data\\Bamboo\\tools\\Maven_3.0.5  
build 07-Nov-2017 13:48:26 Java version: 1.8.0_144, vendor: Oracle Corporation  
build 07-Nov-2017 13:48:26 Java home: D:\\Program Files\\Java\\jdk1.8.0_144\\jre  
build 07-Nov-2017 13:48:26 Default locale: en_US, platform encoding: Cp1252  
build 07-Nov-2017 13:48:26 OS name: "windows server 2012 r2", version: "6.3", arch: "amd64", family: "dos"  
build 07-Nov-2017 13:48:26 \[INFO\] Error stacktraces are turned on.  
build 07-Nov-2017 13:48:26 \[DEBUG\] Reading global settings from D:\\Data\\Bamboo\\tools\\Maven_3.0.5\\conf\\settings.xml  
build 07-Nov-2017 13:48:26 \[DEBUG\] Reading user settings from C:\\Users\\bamboo\\.m2\\settings.xml  
build 07-Nov-2017 13:48:26 \[DEBUG\] Using local repository at C:\\Users\\bamboo\\.m2\\repository  
build 07-Nov-2017 13:48:26 \[DEBUG\] Using manager EnhancedLocalRepositoryManager with priority 10 for C:\\Users\\bamboo\\.m2\\repository  
build 07-Nov-2017 13:48:26 \[INFO\] Scanning for projects...

As you can see the difference is that for the non working build we use JDK 1.6 and for the working build it's 1.8.

Another weird thing is that the Windows version detected is not the same (while it's the same agent that builds both).

Any idea?

Thanks


Answers:
author: Nicolas_Grussenmeyer
body: For anybody facing the same issue we could not find why it's using Administrator account for this specific build so we used the following workaround :

In the Maven settings.xml we added \<localRepository\>C:\\Users\\bamboo\\.m2\\repository\</localRepository\>" in the \<settings\> part of this file.

In the build job, we specified the .m2 settings.xml to use with the maven command : --settings C:\\Users\\bamboo\\.m2\\settings.xml

It does the trick.