我有这个 GitLab CI 组件:
spec:
inputs:
message:
default: test
---
.test-component:
script:
- echo "$[[ inputs.message ]]"
我也有这个管道:
stages:
- test
include:
- component: [my-gitlab-url]/[project-path]/test-component@[commit-sha]
inputs:
message: "This is a test job!"
Demo job:
stage: test
extends:
- test-component
before_script:
- echo "This is before script!"
after_script:
- echo "This is after script!"
“演示作业”按照我想要的方式执行(因此它可以完美地作为模板替换)。但它也自行执行该组件。但我想使用模板等组件,这样我不仅可以外包工作,还可以外包工作的子部分。我怎样才能阻止它自行执行?
在您的演示作业中,您尝试扩展模板
test-component
但该模板不存在。您定义了模板 .test-component
,但试图在不包含 .
的情况下包含它。在您的作业中添加 .
并再次运行它:
Demo job:
stage: test
extends:
- .test-component
before_script:
- echo "This is before script!"
after_script:
- echo "This is after script!"