Skip to content
Snippets Groups Projects
Commit 5b70bcee authored by Dmitriy Zaporozhets's avatar Dmitriy Zaporozhets
Browse files

Merge branch 'specify-working-directory' into 'master'

Add `-C` option to specify the working directory

The concrete goal of adding this switch is to be able to start a runner as:

```
/opt/gitlab-runner/bin/runner -C /home/gitlab-runner
```

This way we can keep the runner's executable code under `/opt/gitlab-runner`, owned by root, and have `/home/gitlab-runner` (or whatever we come up with) as a writable, working area for the gitlab-ci-runner user.

This new switch does not change the default behavior of the runner.

See merge request !14
parents 694106ec bda2eddf
No related branches found
No related tags found
No related merge requests found
Pipeline #
v5.1.0
- Add `-C` command-line option to specify the working directory
v5.0.0
- Async command execution
- All commands executed as single bash script from tempfile
Loading
Loading
Loading
Loading
@@ -97,6 +97,13 @@ CI_SERVER_URL=https://ci.example.com REGISTRATION_TOKEN=replaceme bundle exec ./
 
The registration token can be found at: <http://gitlab-ci-domain.com/admin/runners>, accessible through Header > Runners.
 
By default the configuration file for your new runner gets written in the directory where the gitlab-ci-runner source code was installed, e.g. in `/home/gitlab_ci_runner/gitlab-ci-runner/config.yml`.
You can tell `bin/setup` to use a different directory with the `-C` switch.
```
bin/setup -C /my/runner/working/directory
```
#### Create an Upstart job (Ubuntu, Centos 6)
 
```
Loading
Loading
@@ -135,6 +142,13 @@ cd /home/gitlab_ci_runner/gitlab-ci-runner
bundle exec ./bin/runner
```
 
If you are using a custom working directory you can tell the runner about it with the `-C` switch.
The default working directory is the directory where the gitlab-ci-runner source code was installed, e.g. `/home/gitlab_ci_runner/gitlab-ci-runner`.
```
bundle exec bin/runner -C /my/runner/working/directory
```
### Update
 
In order to update the runner to a new version just go to runner directory and do next:
Loading
Loading
require 'yaml'
require 'optparse'
 
ROOT_PATH = File.expand_path(File.join(File.dirname(__FILE__), ".."))
# The default root path is the path where the gitlab-ci-runner source got
# installed. This may be overridden by the OptionParser below.
$root_path = File.expand_path(File.join(File.dirname(__FILE__), ".."))
 
module GitlabCi
class Config
Loading
Loading
@@ -23,7 +26,7 @@ module GitlabCi
end
 
def builds_dir
@builds_path ||= File.join(ROOT_PATH, 'tmp', 'builds')
@builds_path ||= File.join($root_path, 'tmp', 'builds')
end
 
def write(key, value)
Loading
Loading
@@ -37,7 +40,13 @@ module GitlabCi
private
 
def config_path
File.join(ROOT_PATH, 'config.yml')
File.join($root_path, 'config.yml')
end
end
end
OptionParser.new do |opts|
opts.on('-CWORKING_DIRECTORY', 'Specify the working directory for gitlab-ci-runner') do |v|
$root_path = File.expand_path(v)
end
end.parse!
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment