How can I set runner specific environment variables?

Duncan Tyrell June 26, 2024

I need to be able to set a number of environment variables in order to configure an android development environment to gain access to physical android devices. 

It is not sensible to set the PATH, ANDROID_HOME, and JAVA_HOME environment variables in repository or workspace variables as the installation of the SDK may have variance from runner to runner.

Is there are way I can get the runner to use the .zshrc or .bashrc or otherwise set runner specific variables?

If we do not have the capability our pipelines will be very brittle.

 

I have tried sourcing the .bashrc manually in my pipeline however I got an error:

 

source ~/.bashrc 

bash: /root/.bashrc: No such file or directory

Strangely the HOME environment variable is not set for the runner.

 

This is on a linux-shell runner, version 2.4.0.

1 answer

0 votes
Theodora Boudale
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
June 28, 2024

Hi Duncan,

A Linux Shell runner uses bash to run pipelines steps on your Linux machine, so it has access to the files on the host device.

It is not possible to set runner-specific variables, but you should be able to source files that exist on the host machine.

The error you get indicates that the bash cannot find the file. Does the .bashrc file exist in the /root directory on the machine where the runner is running? If not, could you try providing the path to the file in the source command?

Kind regards,
Theodora

Duncan Tyrell July 8, 2024

Thanks, I think this is probably caused by my attempts to run the runner as a systemd service to auto start the runner.

I was confused as to why the ~ directory was /root since I was thinking about the working directory property of the runner command.

I've moved onto a different approach for now but I may revisit this.

Theodora Boudale
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
July 9, 2024

Thank you for the update, Duncan. Please feel free to reach out if you ever need anything else!

Suggest an answer

Log in or Sign up to answer
DEPLOYMENT TYPE
CLOUD
PRODUCT PLAN
PREMIUM
PERMISSIONS LEVEL
Product Admin
TAGS
AUG Leaders

Atlassian Community Events