Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to use Git command in GitLab-runner?

I’m new to the GitLab CI/CD. I’m having a problem with the continous integration.
This is my config.toml

concurrent = 1
check_interval = 0

[session_server]
  session_timeout = 1800

[[runners]]
  name = "runner-pc"
  url = "https://gitlab.com/"
  token = "xxxxxxxxxxxxxxx"
  executor = "docker"
  [runners.custom_build_dir]
  [runners.cache]
    [runners.cache.s3]
    [runners.cache.gcs]
  [runners.docker]
    tls_verify = false
    image = "docker:19.03.1"
    privileged = false
    disable_entrypoint_overwrite = false
    oom_kill_disable = false
    disable_cache = false
    volumes = ["/var/run/docker.sock:/var/run/docker.sock", "/cache"]
    shm_size = 0

Here is my simple .gitlab-ci.yml

stages:
  - test

job1:
  stage: test
  script:
    - docker --version
    - git --version
  tags:
    - ldc
  only:
    - develop

What I was expecting was to see in the pipeline console is: the version of git
The current result is:
/bin/sh: eval: line 90: git: not found
I just want to use some commands line of Git like git diff, git show, ...
Could you give any hint to find this out?
Thanks for your time!

like image 367
congld2509 Avatar asked Mar 07 '26 01:03

congld2509


1 Answers

Since the default OS of pipeline is Debian, you can try installing Git using apt-get package manager:

stages:
  - test

job1:
  stage: test
  script:
    - apt-get update -qy && apt-get upgrade -qy    # This line used for updating OS repositories
    - apt-get install -y git                       # This command used for installing Git
    - docker --version
    - git --version
  tags:
    - ldc
  only:
    - develop
like image 125
AmirMohammad Dadkhah Avatar answered Mar 08 '26 21:03

AmirMohammad Dadkhah



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!