gitlab ci如何将仓库克隆到docker中?

问题描述:

我熟悉Bamboo,但对gitlab ci还是陌生的,我已经尝试过gitlab几次,发现gitlab的主要优势是自动克隆git存储库

I'm familar with Bamboo but new to gitlab ci, I have tried several times with gitlab and found a key advantage of gitlab is the automatic cloning of git repository.

棘手的部分是gitlab ci甚至可以将存储库自动克隆到Docker容器中

The tricky part is gitlab ci can even clone repository into docker container automatically.

我的git repo:

my git repo:

.git    
.gitlab-ci.yml
foobar.sh

此作业:

  job1:
  stage: run
  image: 
    name: my_image
  script: 
    - ./foobar.sh
    - some other scripts within the docker

可以成功运行。

日志显示拉出my_image后,有一个git clone操作,就像另一个SO 答案说。但是日志不够详细,无法让我知道此命令的触发位置(我不是gitlab ciRunner的所有者,因此,如果有必要,则无法控制日志的详细级别)。

The log shows after pulling my_image, there's a git clone action, like what another SO answer said. but the log isn't detail enough to let me know where this command is triggered(I'm not the owner of gitlab ci runner so cannot control the log verbose level, if it matters).

所以我的问题:


  1. 这是 git clone 命令吗在docker内部还是外部运行?

  2. 如果在docker中,谁触发了它? docker run的完整命令是什么...?

  3. 如果在室外,则将目录挂载到docker的时间和地点是什么?

  1. Is this git clone command run within or outside the docker?
  2. If within, who triggered it? what's the complete command of docker run ...?
  3. If outside, when and where is the directory mounted to docker?

我已经阅读了文档,但是找不到任何解释上述机制的地方。

I have read the docs, but didn't find anywhere to explain above mechanism.


gitlabRunner拉出图像并旋转一个容器。然后从容器内部执行该gitlab存储库的git克隆(由gitlab运行程序执行)。它不是从外面来的,什么也没装。它仅与管道所属的存储库一起使用。

See, the gitlab runner pulls the image and spins up a container. Then from inside the container, a git clone of that gitlab repo is performed (by the gitlab runner). It's not from outside, and nothing is mounted. It works only with the repo where the pipeline belongs to.

如果要克隆另一个仓库,则必须手动将其烘焙到图像中,或者告诉gitlab运行程序进行另一个git克隆。 p>

If you wish to clone another repo, you have to do it manually by either baking it into your image upfront or telling the gitlab runner to perform another git clone.

script:
    - git clone https://github.com/bluebrown/dotfiles

我认为,当未在容器中安装git时,会引起问题。

I assume, that when git is not installed in the container, it causes problems.