gitlab ci:从同一阶段的两个作业传递工件
gitlab ci: Pass artifacts from two jobs of the same stage
有多个作业(不是并行的),我正在尝试将工件从第一个作业传递到第二个作业。
这是它的样子:
deploy-build-docker 1/2:
stage: deploy
image: docker:stable
script:
- ...
artifacts:
paths:
- path
deploy-preprod 2/2:
stage: deploy
image: alpine
dependencies: [deploy-build-docker]
script:
- ....
CI 找不到依赖项,给我这个错误 deploy-preprod 2/2 job: undefined dependency: deploy-build-docker
我也试过deploy
、deploy-build-docker 1/2
,但我仍然遇到同样的问题。
那我该怎么做呢?我应该在另一个阶段进行构建吗?
是的,您只能传递 前 个阶段的工件。
By default, all artifacts from all previous stages are passed, but you can use the dependencies parameter to define a limited list of jobs (or no jobs) to fetch artifacts from.
To use this feature, define dependencies in context of the job and pass a list of all previous jobs from which the artifacts should be downloaded. You can only define jobs from stages that are executed before the current one. An error will be shown if you define jobs from the current stage or next ones.
https://docs.gitlab.com/ee/ci/yaml/#dependencies
尽管他们将来可能会增加对 needs:
的支持,以参考 当前 阶段的工作:https://gitlab.com/gitlab-org/gitlab/issues/30632
有多个作业(不是并行的),我正在尝试将工件从第一个作业传递到第二个作业。
这是它的样子:
deploy-build-docker 1/2:
stage: deploy
image: docker:stable
script:
- ...
artifacts:
paths:
- path
deploy-preprod 2/2:
stage: deploy
image: alpine
dependencies: [deploy-build-docker]
script:
- ....
CI 找不到依赖项,给我这个错误 deploy-preprod 2/2 job: undefined dependency: deploy-build-docker
我也试过deploy
、deploy-build-docker 1/2
,但我仍然遇到同样的问题。
那我该怎么做呢?我应该在另一个阶段进行构建吗?
是的,您只能传递 前 个阶段的工件。
By default, all artifacts from all previous stages are passed, but you can use the dependencies parameter to define a limited list of jobs (or no jobs) to fetch artifacts from.
To use this feature, define dependencies in context of the job and pass a list of all previous jobs from which the artifacts should be downloaded. You can only define jobs from stages that are executed before the current one. An error will be shown if you define jobs from the current stage or next ones.
https://docs.gitlab.com/ee/ci/yaml/#dependencies
尽管他们将来可能会增加对 needs:
的支持,以参考 当前 阶段的工作:https://gitlab.com/gitlab-org/gitlab/issues/30632