gitlab-ci does not execute scripts correctly
<!--- Please read this! Before opening a new issue, make sure to search for keywords in the issues filtered by the "regression" or "bug" label. For the Community Edition issue tracker: - https://gitlab.com/gitlab-org/gitlab-ce/issues?label_name%5B%5D=regression - https://gitlab.com/gitlab-org/gitlab-ce/issues?label_name%5B%5D=bug For the Enterprise Edition issue tracker: - https://gitlab.com/gitlab-org/gitlab-ee/issues?label_name%5B%5D=regression - https://gitlab.com/gitlab-org/gitlab-ee/issues?label_name%5B%5D=bug and verify the issue you're about to submit isn't a duplicate. ---> ### Summary `.gitlab-ci.yml` cannot execute bash script. ### Steps to reproduce I've created a MWE. In the `.gitlab-ci.yml` file, enter this: ```yml build: script: - git diff HEAD^ HEAD --name-only - bash simplescript.sh backend ``` In the root of the project, create the file `simplescript.sh` with the content: ```bash #!/usr/bin/env bash echo "Hello from the simple script" echo "${1}" cmd="git diff HEAD^ HEAD --name-only" echo "Execute ${cmd}" which find find / -name "*git" -type f which git git --version git diff HEAD^ HEAD --name-only ${cmd} ``` ### What is the current *bug* behavior? The current bug is that this fails. I get the following output from the runner ``` Running with gitlab-runner 10.0.2 (a9a76a50) on dev1.company.com (8c3a0808) Using Shell executor... Running on dev1.company.com... Fetching changes... HEAD is now at 5fec64b poop From http://dev1.company.com/Group1/Project-migration-test 5fec64b..5937465 master -> origin/master Checking out 59374655 as master... Skipping Git submodules setup $ git diff HEAD^ HEAD --name-only .gitlab-ci.yml simplescript.sh $ bash simplescript.sh backend Hello from the simple script backend Execute git diff HEAD^ HEAD --name-only which: no find in (/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/home/gitlab-runner/.local/bin:/home/gitlab-runner/bin) find: Arguments to -type should contain only one letter which: no git in (/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/home/gitlab-runner/.local/bin:/home/gitlab-runner/bin) Unknown option: --version usage: git [--version] [--help] [-c name=value] [--exec-path[=<path>]] [--html-path] [--man-path] [--info-path] [-p|--paginate|--no-pager] [--no-replace-objects] [--bare] [--git-dir=<path>] [--work-tree=<path>] [--namespace=<name>] <command> [<args>] usage: git diff [<options>] [<commit> [<commit>]] [--] [<path>...] usage: git diff [<options>] [<commit> [<commit>]] [--] [<path>...] ERROR: Job failed: exit status 1 ``` ### What is the expected *correct* behavior? I would expect something like this, which I get on my local machine ``` % bash simplescript.sh backend Hello from the simple script backend Execute git diff HEAD^ HEAD --name-only /usr/bin/find [...] redacted find for ease of reading [...] /usr/bin/git git version 2.17.0 .gitlab-ci.yml simplescript.sh .gitlab-ci.yml simplescript.sh ``` #### Results of GitLab environment info <details> <summary>Expand for output related to GitLab environment info</summary> <pre> # gitlab-rake gitlab:env:info System information System: Proxy: no Current User: git Using RVM: no Ruby Version: 2.3.6p384 Gem Version: 2.6.13 Bundler Version:1.13.7 Rake Version: 12.3.0 Redis Version: 3.2.11 Git Version: 2.14.3 Sidekiq Version:5.0.5 Go Version: unknown GitLab information Version: 10.6.4-ee Revision: 42f072e Directory: /opt/gitlab/embedded/service/gitlab-rails DB Adapter: postgresql DB Version: 9.6.8 URL: http://dev1.company.com HTTP Clone URL: http://dev1.company.com/some-group/some-project.git SSH Clone URL: git@dev1.company.com:some-group/some-project.git Elasticsearch: no Geo: no Using LDAP: yes Using Omniauth: no GitLab Shell Version: 6.0.4 Repository storage paths: - default: /var/opt/gitlab/git-data/repositories Hooks: /opt/gitlab/embedded/service/gitlab-shell/hooks Git: /opt/gitlab/embedded/bin/git </pre> </details>
issue