Possible to have bamboo load .bashrc?

Chris January 18, 2013

Is there a way to have bamboo load .bashrc or .bash_profile as part of the start up script so I don't have to export custom PATH & environment vars in every Script tasks?


For example, in each Script task anytime we want to do a ruby related script we need to include

# export PATH="$RBENV_ROOT/shims:$RBENV_ROOT/bin:$PATH"

It would be nice if this was loaded automatically somehow.

1 answer

1 accepted

1 vote
Answer accepted
Przemek Bruski
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
January 18, 2013

Instead of calling the Bamboo startup script directly, just source the .bashrc and then call the script. The exoprted variables will be visible to all script tasks run on the local agents. If you want to do the same for remote agents, you need to do the same - i.e. source the dot files first, then run the agent startup command.

Chris January 18, 2013

Is there a way to have it source automatically? I'd just be swapping out one line for another, right?

And to be clear, this is a "Job Task" inside of a plan, not starting up bamboo itself

Chris January 18, 2013

Or are you saying there is a script that launches the elastic agent I can append a source .file to?

Przemek Bruski
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
January 18, 2013

Ah. No, that won't work. The tasks are isolated. Whatever you source in one, won't be visible in others. THe only way to make them available everywhere is to use them during Bamboo startup or Bamboo agent startup.

Przemek Bruski
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
January 18, 2013

Re: elastic agents. Yes, you can do it for the elastic agent. The easiest way is to add the necessary lines to .bashrc of the bamboo user using the instance startup script (have a look at your image configuration).

That script is run before the agent is started, so whatever you do there will be visible to the agent.

Chris January 18, 2013

By instance startup script, do you mean the script that is entered in EC2 that runs on boot (I believe set as `user data` in the launch menu) or a bamboo startup script in the server itself?

Przemek Bruski
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
January 18, 2013

Click edit on your image configuration. You can enter a script there. It will be run right before the agent is started. The script is run as root.

Chris January 18, 2013

awesome, thank you (and thank you for such speedy support!)

jokecamp November 23, 2016

Can you elaborate on where to put the ". ~/.bashrc"

For a ubuntu 14 remote agent I am trying in the "start-agent.sh" file and running "./start-agent.sh"

like so:

. ~/.bashrc
java -Djavax.net.ssl.trustStore=/home/devadmin/keystore -Dbamboo.agent.ignoreServerCertName=true -jar atlassian-bamboo-agent-installer-5.9.1.jar https://mybuildserver/bamboo/agentServer/ start


But the bashrc is still not loading for my tasks.

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events