cDr*_*mer 5 git gitlab docker gitlab-ci-runner
我在 MacBook Pro 上使用 gitlab-runner 和 Docker。我使用 gitlab.com 来托管我的 git 存储库。我已经配置了一个存储库,以便每当提交被推送到存储库时就执行管道。该管道有两个任务:显示一些信息,以及克隆一个单独的存储库作为依赖项。
这是第一个作业的输出:
Running with gitlab-runner 12.2.0 (a987417a)
on old_gen_runner 6fsjs96e
Using Docker executor with image gcc-arm_4_7-2013q3:3.0 ...
Using docker image sha256:5d4741a428654beb44a3c004822e4d2ceededc88f22ec1ec7f45dedf707a0302 for gcc-arm_4_7-2013q3:3.0 ...
Running on runner-6fsjs96e-project-13664495-concurrent-0 via my_laptop.local...
Fetching changes with git depth set to 50...
Initialized empty Git repository in /builds/staging-fw/my-project/.git/
Created fresh repository.
From https://gitlab.com/staging-fw/my-project
* [new branch] master -> origin/master
Checking out 722c2c38 as master...
Skipping Git submodules setup
$ python /scripts/info.py
Printing job info...
Builds dir: /builds
Commit Message:
Modified yml file.
Branch: master
Project dir: /builds/staging-fw/my-project
$ ls /builds
my-project
Run Code Online (Sandbox Code Playgroud)
这是第二个作业的输出:
Running with gitlab-runner 12.2.0 (a987417a)
on old_gen_runner 6fsjs96e
Using Docker executor with image gcc-arm_4_7-2013q3:3.0 ...
Using docker image sha256:5d4741a428654beb44a3c004822e4d2ceededc88f22ec1ec7f45dedf707a0302 for gcc-arm_4_7-2013q3:3.0 ...
Running on runner-6fsjs96e-project-13664495-concurrent-0 via my_laptop.local...
Fetching changes with git depth set to 50...
Reinitialized existing Git repository in /builds/staging-fw/my-project/.git/
Checking out 722c2c38 as master...
Skipping Git submodules setup
$ git clone https://gitlab-ci-token:${CI_JOB_TOKEN}@gitlab.com/staging-fw/my-dependencies.git /builds/dependencies
Cloning into '/builds/dependencies'...
Job succeeded
Run Code Online (Sandbox Code Playgroud)
可以看到,第一次创建pipeline就成功了。
如果我通过推送新的更改再次运行它,以下是第一个作业的输出:
Running with gitlab-runner 12.2.0 (a987417a)
on old_gen_runner 6fsjs96e
Using Docker executor with image gcc-arm_4_7-2013q3:3.0 ...
Using docker image sha256:5d4741a428654beb44a3c004822e4d2ceededc88f22ec1ec7f45dedf707a0302 for gcc-arm_4_7-2013q3:3.0 ...
Running on runner-6fsjs96e-project-13664495-concurrent-0 via my_laptop.local...
Fetching changes with git depth set to 50...
Reinitialized existing Git repository in /builds/staging-fw/my-project/.git/
From https://gitlab.com/staging-fw/my-project
722c2c3..f321b75 master -> origin/master
Checking out f321b75f as master...
Skipping Git submodules setup
$ python /scripts/info.py
Printing job info...
Builds dir: /builds
Commit Message:
Modified yml file.
Branch: master
Project dir: /builds/staging-fw/my-project
$ ls /builds
my-project
dependencies
Job succeeded
Run Code Online (Sandbox Code Playgroud)
正如你所看到的,依赖文件夹仍然存在?不仅如此,Initialized empty Git repository它现在不再像第一份工作的第一次运行时那样说Reinitialized existing Git repository。
以下是第二次运行期间第二个作业上发生的情况:
Running with gitlab-runner 12.2.0 (a987417a)
on old_gen_runner 6fsjs96e
Using Docker executor with image gcc-arm_4_7-2013q3:3.0 ...
Using docker image sha256:5d4741a428654beb44a3c004822e4d2ceededc88f22ec1ec7f45dedf707a0302 for gcc-arm_4_7-2013q3:3.0 ...
Running on runner-6fsjs96e-project-13664495-concurrent-0 via my_laptop.local...
Fetching changes with git depth set to 50...
Reinitialized existing Git repository in /builds/staging-fw/my-project/.git/
Checking out f321b75f as master...
Skipping Git submodules setup
$ git clone https://gitlab-ci-token:${CI_JOB_TOKEN}@gitlab.com/staging-fw/my-dependencies.git /builds/dependencies
fatal: destination path '/builds/dependencies' already exists and is not an empty directory.
ERROR: Job failed: exit code 1
Run Code Online (Sandbox Code Playgroud)
我的问题是:
是/builds为 Docker 中的每个单独容器创建的目录吗?这是我最初的理解,Docker 中的每个容器都有自己单独的 /builds 目录。
该/builds目录是否为所有 Docker 容器共享?我找不到这方面的任何信息。
2a. 如果该/builds目录是所有 Docker 容器共享的,那么它在哪里以及是谁创建的?
GitLab CI/CD 的默认 Git 策略是“fetch”。如果同一个静态运行器反复用于同一个管道,GitLab 将不会进行新的克隆,而只会在后续运行中获取更改。
如果您每次想要“克隆”策略时都想要一个新鲜的环境。有两种方法可以改变这种行为:
git clone.gitlab-ci.yml:variables:
GIT_STRATEGY: clone
Run Code Online (Sandbox Code Playgroud)
您可以在 GitLab 文档 - Git 策略中了解有关此设置的更多信息
| 归档时间: |
|
| 查看次数: |
6076 次 |
| 最近记录: |