how does gitlab ci clone repo into docker?

纵饮孤独 提交于 2019-12-08 05:42:12

问题


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.

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

my git repo:

.git    
.gitlab-ci.yml
foobar.sh

this job:

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

can successfully run.

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).

So my questions:

  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.


回答1:


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.

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

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



来源:https://stackoverflow.com/questions/54661570/how-does-gitlab-ci-clone-repo-into-docker

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!