.gitlab-ci.yml "git: not found"

Hi! I’m new to the forum; I didn’t find this problem reported here or in Stackoverflow. I have an account in gitlab.com where I’m finding a problem with the continous integration.

Here is my simple and simplified .gitlab-ci.yml:

image: docker
- docker:dind

  - apt-get update -qq && apt-get install -y -qq git 
  - git --version

  stage: test
  - echo "hello, world"
    - master

What I was expecting was to see in the pipeline console:

  • the version of git
  • and “hello, world”

The current result is:

$ apt-get update -qq && apt-get install -y -qq git
$ git --version
/bin/sh: eval: line 49: git: not found
ERROR: Job failed: exit code 127

As far as I know, there isn’t a problem with the runners version (I’m using gitlab.com). From this reference (https://docs.gitlab.com/ee/ci/yaml/#git-strategy) with other examples of git commands, I’m assuming that this is something possible. Could you give any hint to find this out?

Thanks for your time!


Ok, finally found it.

  • first of all, “apt-get” doesn’t exist; as it’s an alpine docker, the correct line is:
- apk update && apk add git
  • secondly, the error was shown above the execution of the line, and I just didn’t see it. Thanks to a colleague looking at the code, we finally saw the error messages.



I would also suggest adding apk add --update git && rm -rf /var/cache/apk/* as it is one install command, and one cleanup command