• Community
  • Products
  • Bamboo
  • Questions
  • Why would bamboo-agent as Windows Service not allow PATH setting for Pre-Build-command when running in command shell does?

Why would bamboo-agent as Windows Service not allow PATH setting for Pre-Build-command when running in command shell does?

Peter Kahn August 13, 2012

Hi All,

My 2.6.1 bamboo agents run via a simple batch file and I'm switching them over to run as services using the same user as the batch file.

My plan Sets PATH in System Environment Variables field and runs a Pre Build Command on the agent. In each case my batch file executes set and my "script" executes set displaying the environment.

  • Batch file invocation case uses PATH set in System Environment Variables field when running Pre Build Command batch script
  • Service invocation case does not use PATH set in System Environment Variables field when running Pre Build Command batch script

In both cases, the Script field performs as expected with System Environment Variable's PATH. I can easily set PATH properly in my Pre Build Command batch script file.

I'm perplexed as to why such a thing would happen and from where bamboo was getting the idea of PATH since it didn't match the user's, wrapper confs, or System Environment Variable's PATH.

Please let me know if you have any clue why I'd see this behavior change.

Thanks

Peter

2 answers

0 votes
Sean Dockery August 14, 2012

We have found that Bamboo remote agents are sometime subject to problems that seem to have been addressed in Bamboo proper. In our situation, we noticed that our process had two PATH environment variables, but they were different case. Essentially, we suffered from https://jira.atlassian.com/browse/BAM-1660 on our Bamboo 3.1 remote agent, while that particular issue was supposed to have been fixed in Bamboo 1.2.3. The clue was that the Path and PATH environment variables were listed multiple times in the build log.

The solution was to make sure that the case of the PATH environment variable matched everywhere so that the Bamboo remote agent could decorate it properly. If we use PATH in our build plan, we needed to ensure that the environment variable was named PATH on the remote agent. Your situation doesn't sound exactly like ours, but it is a suggestion.

0 votes
Przemek Bruski
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
August 14, 2012

Does this KB article match what you're seeing http://support.microsoft.com/kb/887693 / http://support.microsoft.com/kb/821761 ?

Peter Kahn August 14, 2012

I dont think so, but I have run into that one before. I'm changing the path variable in the execution environment via the plan not via the control panel applet.

The funny thing is that the setting of PATH from the plan works for the "script" execution in either case but only for the pre-build script has a problem in the service case. It's weird because I set JAVA_HOME and that works in all cases, but path not so much. My solution was to move path into the script = set PATH=%JAVA_HOME%\bin;%PATH% I'd expect that to fail if environment variables aren't set.

Another possibility is that the pre-build-script forks a shell whci gets variables from the plan setting and the registry setting. He who sets the variable last wins and the env var set by bamboo is overriden by those from the registry. Since JAVA_HOME isn't in the user's env on the plan's notion of env it goes through.

In the case of the run-from script the execution environment fro pre-build-script is a subshell but when run from the service it is different for some reason having to do with service magic.

Peter

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events