Commit 5b70bcee authored by Dmitriy Zaporozhets's avatar Dmitriy Zaporozhets

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
Pipeline #243 passed with stage
- Add `-C` command-line option to specify the working directory
- Async command execution
- All commands executed as single bash script from tempfile
......@@ -97,6 +97,13 @@ CI_SERVER_URL= REGISTRATION_TOKEN=replaceme bundle exec ./
The registration token can be found at: <>, 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)
......@@ -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:
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
......@@ -23,7 +26,7 @@ module GitlabCi
def builds_dir
@builds_path ||= File.join(ROOT_PATH, 'tmp', 'builds')
@builds_path ||= File.join($root_path, 'tmp', 'builds')
def write(key, value)
......@@ -37,7 +40,13 @@ module GitlabCi
def config_path
File.join(ROOT_PATH, 'config.yml')
File.join($root_path, 'config.yml')
end do |opts|
opts.on('-CWORKING_DIRECTORY', 'Specify the working directory for gitlab-ci-runner') do |v|
$root_path = File.expand_path(v)
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment