gitlab-runner exec docker does not execute global after_script and before_script properly
Summary
When the runner is used to test a configuration with exec docker, after_script is not executed if it has been defined in the global scope.
before_script on the other hand works as expected if defined in the global scope, but not if inside a default: block.
Steps to reproduce
git clone git@gitlab.com:niosHD/mwe-gitlabci-paths.git
cd mwe-gitlabci-paths
gitlab-runner exec docker job1
Actual behavior
The global after_script commands are not executed.
Expected behavior
Globally defined after_script or one defined in default: is executed like on the official Gitlab CI runners and similarly like locally defined after_script is executed. (e.g., gitlab-runner exec docker job2)
Relevant logs and/or screenshots
Incorrect output where no after_script is executed:
Running with gitlab-ci-multi-runner 9.2.0 (adfc387)
on ()
Using Docker executor with image ubuntu:16.04 ...
Using docker image sha256:8fc3a7eccb276aae30ed9e67da418a69055f6f0bf047a501355ab09f79f427b5 for predefined container...
Pulling docker image ubuntu:16.04 ...
Using docker image ubuntu:16.04 ID=sha256:ebcd9d4fca80e9e8afc525d8a38e7c56825dfb4a220ed77156f9fb13b14d4ab7 for build container...
Running on runner--project-0-concurrent-0 via t440smw...
Cloning repository...
Cloning into '/builds/project-0'...
done.
Checking out 65899193 as master...
Skipping Git submodules setup
$ echo "global before_script"
global before_script
$ mkdir _build
$ cd _build
$ pwd
/builds/project-0/_build
$ echo "job1"
job1
$ pwd
/builds/project-0/_build
Running after script...
Job succeeded
Environment description
% docker info
Containers: 0
Running: 0
Paused: 0
Stopped: 0
Images: 5
Server Version: 17.05.0-ce
Storage Driver: aufs
Root Dir: /var/lib/docker/aufs
Backing Filesystem: extfs
Dirs: 10
Dirperm1 Supported: true
Logging Driver: json-file
Cgroup Driver: cgroupfs
Plugins:
Volume: local
Network: bridge host macvlan null overlay
Swarm: inactive
Runtimes: runc
Default Runtime: runc
Init Binary: docker-init
containerd version: 9048e5e50717ea4497b757314bad98ea3763c145
runc version: 9c2d8d184e5da67c95d601382adf14862e4f2228
init version: 949e6fa
Security Options:
apparmor
seccomp
Profile: default
Kernel Version: 4.4.0-78-generic
Operating System: Ubuntu 16.04.2 LTS
OSType: linux
Architecture: x86_64
CPUs: 4
Total Memory: 11.45GiB
Name: xxxxxx
ID: xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
Docker Root Dir: /var/lib/docker
Debug Mode (client): false
Debug Mode (server): false
Registry: https://index.docker.io/v1/
Experimental: false
Insecure Registries:
127.0.0.0/8
Live Restore Enabled: false
WARNING: No swap limit support
Used GitLab Runner version
% gitlab-runner -v
Version: 9.2.0
Git revision: adfc387
Git branch: 9-2-stable
GO version: go1.7.5
Built: Mon, 22 May 2017 16:00:24 +0000
OS/Arch: linux/amd64
Edited by 🤖 GitLab Bot 🤖