VirtualBox executor exports relative CI_PROJECT_DIR if runners.builds_dir not set
When using the VirtualBox executor, the guest runner sees a relative CI_PROJECT_DIR
path instead of an absolute path. This breaks build workflows that use CI_PROJECT_DIR
because the path is relative to the ssh user's $HOME
, not the local repo / current directory. Per documentation, CI_PROJECT_DIR
should always be an absolute path. #216 (closed) may be related.
A workaround is to explicitly set runners.builds_dir
in config.toml
, like so:
concurrent = 1
check_interval = 0
[[runners]]
name = "workstation"
url = "[REDACTED]"
token = "[REDACTED]"
executor = "virtualbox"
builds_dir = "/Users/admin/builds" ### <---
[runners.ssh]
user = "admin"
password = "password"
identity_file = "/Users/me/tmp/builder/k_rsa"
[runners.docker]
tls_verify = false
image = ""
privileged = false
disable_cache = false
[runners.parallels]
base_name = ""
disable_snapshots = false
[runners.virtualbox]
base_name = "elcapitan"
disable_snapshots = true
base_snapshot = "ci-runner-base"
[runners.cache]
Using a .gitlab-ci.yml
that simply runs env
, here is the build log without runners.builds_dir
setting:
Running with gitlab-ci-multi-runner dev (HEAD)
Using VirtualBox version 5.1.4r110228 executor...
Creating new VM...
Waiting VM to become responsive...
Starting SSH command...
Running on elcapitan.local via axon.local...
Cloning repository...
Cloning into 'builds/git/dev/test'...
Checking out 26ca2668 as master...
$ env | tee out.txt
CI_PROJECT_NAME=test
CI_BUILD_TOKEN=[REDACTED]
CI_PROJECT_URL=[REDACTED]
SHELL=/bin/bash
SSH_CLIENT=10.0.2.2 49911 22
TMPDIR=/var/folders/1v/gjc_w33x6bb8d2fk_vh91hw80000gn/T/
CI_BUILD_BEFORE_SHA=26ca26685358d903297b9d62fd42ee5519a4310a
CI_SERVER_VERSION=8.11.5
CI_BUILD_ID=256
OLDPWD=/Users/admin
USER=admin
CI_PROJECT_ID=6
CI_RUNNER_ID=13
CI_PIPELINE_ID=150
CI_BUILD_REF_NAME=master
CI_BUILD_REF=26ca26685358d903297b9d62fd42ee5519a4310a
PATH=/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin
MAIL=/var/mail/admin
CI_BUILD_STAGE=test
CI_PROJECT_DIR=builds/git/dev/test
CI_RUNNER_TAGS=ios, awscli, nodejs, osx, ruby
PWD=/Users/admin/builds/git/dev/test
CI_PROJECT_PATH=dev/test
CI_SERVER_NAME=GitLab
GITLAB_CI=true
CI_SERVER_REVISION=f1ce997
CI_BUILD_NAME=job
HOME=/Users/admin
SHLVL=2
CI_SERVER=yes
CI=true
CI_PROJECT_NAMESPACE=dev
LOGNAME=admin
SSH_CONNECTION=10.0.2.2 49911 10.0.2.15 22
CI_BUILD_REPO=[REDACTED]
CI_RUNNER_DESCRIPTION=axon
_=/usr/bin/env
Uploading artifacts...
out.txt: found 1 matching files
Uploading artifacts to coordinator... ok id=256 responseStatus=201 Created token=Xs4ceGMz
Build succeeded
And here is the build log with explicit runner.builds_dir
setting:
Running with gitlab-ci-multi-runner dev (HEAD)
Using VirtualBox version 5.1.4r110228 executor...
Creating new VM...
Waiting VM to become responsive...
Starting SSH command...
Running on elcapitan.local via workstation.local...
Cloning repository...
Cloning into '/Users/admin/builds/git/dev/test'...
Checking out 26ca2668 as master...
$ env | tee out.txt
CI_PROJECT_NAME=test
CI_BUILD_TOKEN=[REDACTED]
CI_PROJECT_URL=[REDACTED]
SHELL=/bin/bash
SSH_CLIENT=10.0.2.2 64936 22
TMPDIR=/var/folders/1v/gjc_w33x6bb8d2fk_vh91hw80000gn/T/
CI_BUILD_BEFORE_SHA=26ca26685358d903297b9d62fd42ee5519a4310a
CI_SERVER_VERSION=8.11.5
CI_BUILD_ID=254
OLDPWD=/Users/admin
USER=admin
CI_PROJECT_ID=6
CI_RUNNER_ID=13
CI_PIPELINE_ID=150
CI_BUILD_REF_NAME=master
CI_BUILD_REF=26ca26685358d903297b9d62fd42ee5519a4310a
PATH=/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin
MAIL=/var/mail/admin
CI_BUILD_STAGE=test
CI_PROJECT_DIR=/Users/admin/builds/git/dev/test
CI_RUNNER_TAGS=ios, awscli, nodejs, osx, ruby
PWD=/Users/admin/builds/git/dev/test
CI_PROJECT_PATH=dev/test
CI_SERVER_NAME=GitLab
GITLAB_CI=true
CI_SERVER_REVISION=f1ce997
CI_BUILD_NAME=job
HOME=/Users/admin
SHLVL=2
CI_SERVER=yes
CI=true
CI_PROJECT_NAMESPACE=dev
LOGNAME=admin
SSH_CONNECTION=10.0.2.2 64936 10.0.2.15 22
CI_BUILD_REPO=[REDACTED]
CI_RUNNER_DESCRIPTION=workstation
_=/usr/bin/env
Uploading artifacts...
out.txt: found 1 matching files
Uploading artifacts to coordinator... ok id=254 responseStatus=201 Created token=Xs4ceGMz
Build succeeded
The only difference is the CI_PROJECT_DIR
var. I suspect this has something to do with how the DefaultBuildsDir
option is used in executors/*
.
This is gitlab-ci-multi-runner
1.5.3 via Homebrew on OS X 10.11.6. Likewise for the VirtualBox guest.