想象一下有几个阶段:
stages:
- test
- build
- deploy需要将test阶段划分为较小的任务,如build-test-image、pytest、run-linters等。作业run-tests、run-linters只有在build-test-image工作时才能运行。
我试过了,但没有用:
build-test-image:
stage: test
image: ${DOCKER_REGISTRY}/docker:stable
script:
- docker build -t ${TEST_CONTAINER_REF} --build-arg ENV=test ./backend
artifacts:
when: always
only:
- merge_requests
pytest:
stage: test
image: ${DOCKER_REGISTRY}/docker:stable
script:
- docker run --name ${TEST_CONTAINER_REF} -e SECRET_KEY=${TEST_SECRET_KEY} ${TEST_CONTAINER_REF} runtests; exit $?
after_script:
- docker rm ${TEST_CONTAINER_REF}
only:
- merge_requests
needs:
- build-test-image错误:

发布于 2022-02-01 17:33:39
原则上,如果一个作业声明了一个needs语句,那么为了执行这个作业,它必须对语句中引用的要完成的作业( even if they are in the same stage )进行wait。
在您的例子中,run-tests应该等待build-test-image。
如果您使用的是自托管版本,请检查Gitlab版本
https://your.domain.com/help您需要的功能是在14.2中添加的

https://stackoverflow.com/questions/70943030
复制相似问题