使用 extends 关键字的 GitLab Pipeline 错误
当我为存储库提交下一个 .gitlab-ci.yml 时,我在 GitLab Pipeline 上遇到错误。
- 构建解决方案、部署到 Artifactory 以及触发和 API 调用所执行的管道
- 部署作业必须手动执行,并且有两个不同的作业选项可以执行。
stages:
- build
- deploy
- trigger
variables:
APP_PROJECT_ID: ${CUSTOMER_RELEASED}
build_job:
stage: build
tags:
- dotnet
script:
- echo "build"
only:
- tags
allow_failure: false
.deploy_job_base:
stage: deploy
needs: [build_job]
tags:
- dotnet
script:
- echo "deploy"
dependencies:
- build_job
only:
- tags
deploy_job_sport:
extends: .deploy_job_base
after_script:
- $APP_PROJECT_ID = "2096"
when: manual
allow_failure: false
deploy_job_others:
extends: .deploy_job_base
after_script:
- $APP_PROJECT_ID = "0"
when: manual
allow_failure: false
.trigger_base:
stage: trigger
script:
- echo "Customer Project ID '{$APP_PROJECT_ID}'"
- echo "Call API..."
trigger_sport:
extends: .trigger_base
needs: [deploy_job_sport]
trigger_others:
extends: .trigger_base
needs: [deploy_job_others]
Lint 状态正确 但是当我提交更改时,我收到了 GitLab Pipeline 错误:
在您的 .gitlab-ci.yml 中发现错误:“trigger_sport”工作需求 “deploy_job_sport”作业,但“deploy_job_sport”不在之前的任何作业中 阶段“trigger_others”作业需要“deploy_job_others”作业,但是 “deploy_job_others”不处于任何先前阶段
如果我删除trigger_sport和trigger_others作业并仅创建一个作业,它工作正常,但我不知道如何将两个手动作业(deploy_job_sport和deploy_job_others)定位到单个作业。 你有什么想法吗? 提前致谢。
I got an error on GitLab Pipeline when I commit the next .gitlab-ci.yml for a repository.
- Pipeline executed to build solution, deploy to Artifactory and trigger and API call
- Deploy job have to be executed manually, and there are two different job options to execute.
stages:
- build
- deploy
- trigger
variables:
APP_PROJECT_ID: ${CUSTOMER_RELEASED}
build_job:
stage: build
tags:
- dotnet
script:
- echo "build"
only:
- tags
allow_failure: false
.deploy_job_base:
stage: deploy
needs: [build_job]
tags:
- dotnet
script:
- echo "deploy"
dependencies:
- build_job
only:
- tags
deploy_job_sport:
extends: .deploy_job_base
after_script:
- $APP_PROJECT_ID = "2096"
when: manual
allow_failure: false
deploy_job_others:
extends: .deploy_job_base
after_script:
- $APP_PROJECT_ID = "0"
when: manual
allow_failure: false
.trigger_base:
stage: trigger
script:
- echo "Customer Project ID '{$APP_PROJECT_ID}'"
- echo "Call API..."
trigger_sport:
extends: .trigger_base
needs: [deploy_job_sport]
trigger_others:
extends: .trigger_base
needs: [deploy_job_others]
Lint status is correct
but I get that error GitLab Pipeline when I commit changes:
Found errors in your .gitlab-ci.yml: 'trigger_sport' job needs
'deploy_job_sport' job but 'deploy_job_sport' is not in any previous
stage 'trigger_others' job needs 'deploy_job_others' job but
'deploy_job_others' is not in any previous stage
If I remove trigger_sport and trigger_others job and create only one job, it works fine but I don't know how I can target the two manual jobs (deploy_job_sport and deploy_job_others) to a single job.
Do you have any idea?
Thanks in advance.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我认为这与您在模板中使用
only:tags
进行部署作业有关,并且构建作业也仅限于在提交包含tag
时运行。但是触发器模板缺少此限制,这很可能在推送没有标记的提交时导致此错误,因为管道创建会将
trigger_XY
添加到管道,该管道依赖于之前的deploy_XY< /代码> 工作。
将触发器作业的作业模板更新为以下内容时,应解决此错误:
I think this is related to the fact that you're using
only: tags
in your template for deploy jobs and the build job also is limited to run when commits contain atag
.But the trigger template is missing this limitation which most likely causes this error when pushing a commit without a tag because the pipeline creation would add
trigger_XY
to the pipeline, which has dependencies to the previousdeploy_XY
jobs.When updating your job template for trigger jobs to the following this error should be resolved: