Why the Bamboo $PATH variable is different

Hi,

I would like to know why the command echo $PATH is different in terminal and Bamboo CLI Task. In Terminal looks like

bamboo@vagrant-ubuntu-trusty-64:~$ echo $PATH
/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/home/bamboo/.rvm/bin

and within the task like this

22-Dec-2014 10:48:14
Starting task 'echo $PATH' of type 'com.atlassian.bamboo.plugins.scripttask:task.builder.script'
22-Dec-2014 10:48:14
/usr/local/bin:/usr/bin:/bin:/usr/local/games:/usr/games
22-Dec-2014 10:48:14
Finished task 'echo $PATH' with result: Success

 

Any idea why this both commands return different results?

1 answer

1 accepted

1 vote
Accepted answer

Paths are derived from parent processes and if there is none from the users and the global profile (Linux service). So basically the path depends on how a process is started.

Hi @Mike Friedrich, thanks for your answer! The solution of my problem was the following line in the startup script in /etc/init.d. /bin/su -m $USER -c "cd $BASE/logs && $BASE/bin/startup.sh &> /dev/null" I replace the -m argument with an normal hyphen (-), so the bamboo start with login shell of the bamboo user /bin/su - $USER -c "cd $BASE/logs && $BASE/bin/startup.sh &> /dev/null"

I would always prefer the single dash way, also for security reasons. Make sure there is no variable in the init script which the startup.sh needs.

I agree with MIke. You could set the PATH in startup.sh that way its not dependent on the interactive login account.

Suggest an answer

Log in or Sign up to answer
Community showcase
Asked Dec 06, 2018 in Jira Ops

I'm John Allspaw, Ask Me Anything about incident analysis and postmortems

I'm John Allspaw, co-founder of   Adaptive Capacity Labs, where we help teams use their incidents to learn and improve. We bring research-driven methods and approaches to drive effective inciden...

5,608 views 22 17
View question

Atlassian User Groups

Connect with like-minded Atlassian users at free events near you!

Find a group

Connect with like-minded Atlassian users at free events near you!

Find my local user group

Unfortunately there are no AUG chapters near you at the moment.

Start an AUG

You're one step closer to meeting fellow Atlassian users at your local meet up. Learn more about AUGs

Groups near you