简体   繁体   English

如何在 GitLab-runner 中使用 Git 命令?

[英]How to use Git command in GitLab-runner?

I'm new to the GitLab CI/CD.我是 GitLab CI/CD 的新手。 I'm having a problem with the continous integration.我在持续集成方面遇到问题。
This is my config.toml这是我的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这是我的简单.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期望在管道控制台中看到的是: 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 , ...我只想使用 Git 的一些命令行,例如git diffgit show ,...
Could you give any hint to find this out?你能给出任何提示来找出答案吗?
Thanks for your time!谢谢你的时间!

Since the default OS of pipeline is Debian , you can try installing Git using apt-get package manager:由于管道的默认操作系统是Debian ,您可以尝试使用apt-get package 管理器安装Git

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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM