如何使用 Gitlab CI-Component 进行扩展?

问题描述 投票:0回答:1

我有这个 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!"

“演示作业”按照我想要的方式执行(因此它可以完美地作为模板替换)。但它也自行执行该组件。但我想使用模板等组件,这样我不仅可以外包工作,还可以外包工作的子部分。我怎样才能阻止它自行执行?

这显示了两个作业(但我只想执行“演示作业”):

gitlab yaml continuous-integration components pipeline
1个回答
0
投票

在您的演示作业中,您尝试扩展模板

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!"
© www.soinside.com 2019 - 2024. All rights reserved.