Skip to content

global before_script not executed when job has an own before_script

Summary

When a job has a before script, the global before script is not executed.

Steps to reproduce

Consider the following .gitlab-ci.yml:

image: node6

before_script:
  - yarn install --force

stages:
  - lint
  - test
  - translations
  - deploy

...

deploy_test:
  stage: deploy
  only:
    - develop
  cache:
    key: "$CI_BUILD_NAME"
    paths:
      - node_modules
  before_script:
    - eval $(ssh-agent -s)
    - ssh-add <(echo "$SSH_PRIVATE_KEY")
    - mkdir -p ~/.ssh
    # Disable strict host key checking for Docker builds
    - '[[ -f /.dockerenv ]] && echo -e "Host *\n\tStrictHostKeyChecking no\n\n" > ~/.ssh/config'
  script:
    - npm run deploy-test

Actual behavior

When the job deploy_test is executed, yarn install --force is not executed.

Expected behavior

When the job deploy_test is executed, yarn install --force should be executed.

Relevant logs and/or screenshots

Running with gitlab-ci-multi-runner 1.11.1 (a67a225)
  on gitlab-runner-2 (2c6accbe)
Using Docker executor with image node6 ...
Running on runner-2c6accbe-project-93-concurrent-0 via gitlab-runner-2...
Cloning repository...
Cloning into '/builds/ProjectNamespace/Project'...
Checking out 92a82115 as develop...
Skipping Git submodules setup
Checking cache for deploy_test...
Successfully extracted cache
$ eval $(ssh-agent -s)
Agent pid 10
$ ssh-add <(echo "$SSH_PRIVATE_KEY")
Identity added: /dev/fd/63 (rsa w/o comment)
$ mkdir -p ~/.ssh
$ [[ -f /.dockerenv ]] && echo -e "Host *\n\tStrictHostKeyChecking no\n\n" > ~/.ssh/config
$ npm run deploy-test

Environment description

Custom installation, Debian Jessie

Containers: 2
 Running: 0
 Paused: 0
 Stopped: 2
Images: 3
Server Version: 17.03.0-ce
Storage Driver: aufs
 Root Dir: /var/lib/docker/aufs
 Backing Filesystem: extfs
 Dirs: 37
 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: 977c511eda0925a723debdc94d09459af49d082a
runc version: a01dafd48bc1c7cc12bdb01206f9fea7dd6feb70
init version: 949e6fa
Kernel Version: 3.16.0-4-amd64
Operating System: Debian GNU/Linux 8 (jessie)
OSType: linux
Architecture: x86_64
CPUs: 4
Total Memory: 1.963 GiB
Name: gitlab-runner-2
ID: C3FD:KTBB:J7N7:66A4:G7RG:YWBW:RFHP:L5EW:7NGJ:2QAJ:LFA5:QZ5M
Docker Root Dir: /var/lib/docker
Debug Mode (client): false
Debug Mode (server): false
Registry: https://index.docker.io/v1/
WARNING: No memory limit support
WARNING: No swap limit support
WARNING: No kernel memory limit support
WARNING: No oom kill disable support
WARNING: No cpu cfs quota support
WARNING: No cpu cfs period support
Experimental: false
Insecure Registries:
 127.0.0.0/8
Live Restore Enabled: false

Used GitLab Runner version

Version:      1.11.1
Git revision: a67a225
Git branch:   1-11-stable
GO version:   go1.7.5
Built:        Fri, 03 Mar 2017 12:35:58 +0000
OS/Arch:      linux/amd64