If I have a GitLab CI/CD Component, is there a way to override configuration values? I'm specifically thinking of things like needs or rules. spec:inputs
seems to be the only way to pass configuration information but it is very limited, only supporting strings, numbers and booleans. This is what I would like to do:
templates/publish.yml
spec:
inputs:
job-name:
default: Publish
stage:
default: Publish
rules:
default: []
needs:
default: []
---
$[[ inputs.job-name ]]:
image: python:3.12.2-alpine3.19
stage: $[[ inputs.stage ]]
rules: $[[ inputs.rules ]]
needs: $[[ inputs.needs ]]
script:
...
gitlab-ci.yml
include:
- component: $CI_SERVER_HOST/components/publish@latest
inputs:
stage: Publish
needs:
- job: Build
rules:
if: $CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH
stages:
- Build
- Publish
Build:
...
I thought CI/CD Components were supposed to be a better way to reuse jobs but so far it seems much more restrictive than extending a hidden job. What am I missing?
The feature I was looking for already exists just by overriding properties on the job after including the component as sytech pointed out. This is what I was looking for
templates/publish.yml
spec:
inputs:
job-name:
default: Publish
stage:
default: Publish
---
$[[ inputs.job-name ]]:
image: python:3.12.2-alpine3.19
stage: $[[ inputs.stage ]]
script:
...
gitlab-ci.yml
include:
- component: $CI_SERVER_HOST/components/publish/publish@~latest
Publish: # This is the included job
needs: # Add needs
- job: Build
rules: # Add rules
if: $CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH
stages:
- Build
- Publish
Build:
...