我遇到了一个问题,即在测试阶段的第一份工作在我也没想到的情况下会收到我之前的建造工作的全部状态。为了尽可能重现该问题,我已尽可能简化了该问题。本质上,构建运行并签出我的仓库。 ls -al打印出包含我签出的仓库的工作目录。 test-one运行,跳过git checkout,并打印包含先前构建作业中git checkout的工作目录。运行test-two,跳过git checkout,并打印包含预期空目录的工作目录。
我的问题是,我是否错误地配置了.gitlab-ci.yml文件?我的期望是否缺乏对GitLab应该如何工作的理解?是否是GitLab或运行程序的配置不正确?或者这是一个错误吗?
注意事项:
下面是简化的.gitlab-ci.yml文件:
image: $DOCKER_REGISTRY/my-image:latest
build:
stage: build
tags:
- linux-runner
script:
- ls -al
test-one:
stage: test
tags:
- linux-runner
variables:
GIT_STRATEGY: none
script:
- ls -al
test-two:
stage: test
tags:
- linux-runner
variables:
GIT_STRATEGY: none
script:
- ls -al
答案 0 :(得分:0)
这似乎是由于我使用GIT_STRATEGY引起的:无。通过删除变量,我再次开始收到预期的行为。
答案 1 :(得分:0)
图片:$ DOCKER_REGISTRY / my-image:latest
stages: # <-- add them all
- build
- test1
- test2
build:
stage: build
tags:
- linux-runner
script:
- ls -al
test-one:
stage: test1 # <-- change this
tags:
- linux-runner
variables:
GIT_STRATEGY: none
script:
- ls -al
test-two:
stage: test2 # <-- change this
tags:
- linux-runner
variables:
GIT_STRATEGY: none
script:
- ls -al
根据您的情况,test-one
和test-two
具有相同的“种类”环境。
通过设置两个不同的阶段,他们将拥有自己的环境