Skip to content

Commit ac2d2b8

Browse files
authored
Merge pull request circleci#7031 from circleci/RT-552/update-runner-working-directory
RT-522: update working directory for runner
2 parents 6efae91 + 84a1c32 commit ac2d2b8

File tree

3 files changed

+23
-8
lines changed

3 files changed

+23
-8
lines changed

jekyll/_cci2/runner-config-reference.adoc

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,9 @@ runner:
104104
=== runner.working_directory
105105
`$LAUNCH_AGENT_RUNNER_WORK_DIR`
106106

107-
This directory takes a fully qualified path and allows you to control the default working directory used by each job. If the directory already exists, the task agent will need permissions to write to the directory. If the directory does not exist, then the task agent will need permissions to create the directory. If `%s` is present in the value, this value will be replaced with a different value for each job. Note that these directories will not automatically be removed.
107+
This directory takes a fully qualified path and allows you to control the default working directory used by each job. If the directory already exists, the task agent will need permissions to write to the directory. If the directory does not exist, then the task agent will need permissions to create the directory. If installing multiple launch-agents on the same machine, each launch-agent will need a unique working directory.
108+
109+
NOTE: These directories will not automatically be removed, please see `cleanup_working_directory` to configure cleanup of directory.
108110

109111
Example:
110112

@@ -113,6 +115,17 @@ runner:
113115
working_directory: /opt/circleci/workdir
114116
```
115117

118+
CircleCI recommends using a knowable directory, however it is possbile to specify `%s` in the path. This value will be replaced with a different value for each job. This is a substitution that is only knowable at job runtime, under the environment variable `$CIRCLE_WORKING_DIRECTORY`.
119+
120+
Example:
121+
122+
```yaml
123+
runner:
124+
working_directory: /opt/circleci/%s
125+
```
126+
127+
128+
116129
=== runner.cleanup_working_directory
117130
`$LAUNCH_AGENT_RUNNER_CLEANUP_WORK_DIR`
118131

@@ -253,4 +266,4 @@ jobs:
253266
steps:
254267
- run: echo "Hi I'm on Runners!"
255268
```
256-
The job will then execute using your self-hosted runner when you push the config to your VCS provider.
269+
The job will then execute using your self-hosted runner when you push the config to your VCS provider.

jekyll/_cci2/runner-installation-linux.adoc

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ api:
3636
runner:
3737
name: RUNNER_NAME
3838
command_prefix: ["sudo", "-niHu", "USERNAME", "--"]
39-
working_directory: /opt/circleci/workdir/%s
39+
working_directory: /var/opt/circleci/workdir
4040
cleanup_working_directory: true
4141
```
4242

@@ -71,8 +71,9 @@ These will be used when executing the task agent. These commands must be run as
7171
```shell
7272
id -u USERNAME &>/dev/null || sudo adduser --disabled-password --gecos GECOS USERNAME
7373

74-
sudo mkdir -p /opt/circleci/workdir
75-
sudo chown -R USERNAME /opt/circleci/workdir
74+
sudo mkdir -p /var/opt/circleci/workdir
75+
sudo chown -R USERNAME /var/opt/circleci/workdir
76+
sudo chmod 0750 /var/opt/circleci/workdir
7677
```
7778

7879
Consider running the following additional command if you would like to use certified orbs that work on Cloud on your self-hosted runner, without errors. Note that this enables code to execute root commands on your machine, and changes to the system may persist after the job is run.
@@ -87,8 +88,9 @@ echo "USERNAME ALL=(ALL) NOPASSWD:ALL" >> /etc/sudoers
8788
```shell
8889
id -u USERNAME &>/dev/null || sudo adduser -c GECOS USERNAME
8990

90-
sudo mkdir -p /opt/circleci/workdir
91-
sudo chown -R USERNAME /opt/circleci/workdir
91+
sudo mkdir -p /var/opt/circleci/workdir
92+
sudo chown -R USERNAME /var/opt/circleci/workdir
93+
sudo chmod 0750 /var/opt/circleci/workdir
9294
```
9395

9496
Consider running the following additional command if you would like to use certified orbs that work on Cloud on your self-hosted runner, without errors. Note that this enables code to execute root commands on your machine, and changes to the system may persist after the job is run.

jekyll/_cci2/runner-installation-mac.adoc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ api:
3131
runner:
3232
name: RUNNER_NAME
3333
command_prefix : ["sudo", "-niHu", "USERNAME", "--"]
34-
working_directory: /tmp/%s
34+
working_directory: /var/opt/circleci/workdir
3535
cleanup_working_directory: true
3636

3737
logging:

0 commit comments

Comments
 (0)