使用 extends 关键字的 GitLab 管道错误
GitLab Pipeline error using extends keyword
当我为存储库提交下一个 .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:
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
如果我删除 trigger_sport 和 trigger_others 作业并只创建一个作业,它工作正常但我不知道如何定位两个手动作业(deploy_job_sport 和deploy_job_others) 到单个作业。
你有什么主意吗?
提前致谢。
我认为这与您在部署作业模板中使用 only: tags
并且当提交包含 tag
.
但是触发器模板缺少此限制,这很可能在推送不带标记的提交时导致此错误,因为管道创建会将 trigger_XY
添加到管道,该管道依赖于之前的 [=14] =] 职位。
将触发器作业的作业模板更新为以下内容时,应解决此错误:
.trigger_base:
stage: trigger
script:
- echo "Customer Project ID '{$APP_PROJECT_ID}'"
- echo "Call API..."
only:
- tags
当我为存储库提交下一个 .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 状态正确
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
如果我删除 trigger_sport 和 trigger_others 作业并只创建一个作业,它工作正常但我不知道如何定位两个手动作业(deploy_job_sport 和deploy_job_others) 到单个作业。 你有什么主意吗? 提前致谢。
我认为这与您在部署作业模板中使用 only: tags
并且当提交包含 tag
.
但是触发器模板缺少此限制,这很可能在推送不带标记的提交时导致此错误,因为管道创建会将 trigger_XY
添加到管道,该管道依赖于之前的 [=14] =] 职位。
将触发器作业的作业模板更新为以下内容时,应解决此错误:
.trigger_base:
stage: trigger
script:
- echo "Customer Project ID '{$APP_PROJECT_ID}'"
- echo "Call API..."
only:
- tags