I have this GitLab CI-Component:
spec:
inputs:
message:
default: test
---
.test-component:
script:
- echo "$[[ inputs.message ]]"
Also I have this Pipeline:
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!"
The "Demo job" is executed like I wanted (so it works perfectly as a template substitution there). But it also executes the component on its own. But I want to work with components like templates so I can not only outsource jobs but also sub parts of jobs. How can I stop it from executing on its own?
This shows the two jobs (but I only want "Demo job" to be executed):
In your Demo Job you're trying to extend the template test-component
but that doesn't exist. You defined the template .test-component
, but are trying to include it without the .
. Add the .
in your job and run it again:
Demo job:
stage: test
extends:
- .test-component
before_script:
- echo "This is before script!"
after_script:
- echo "This is after script!"