Hi everyone,
I’m creating a separate repository to store GitLab CI job templates. My goal is to use the include
feature so that other projects can easily add a default job, while still allowing them to configure certain variables through inputs
.
Here’s what I’ve done:
In the template project (templates/pre-build.gitlab-ci.yml
):
spec:
inputs:
PRE_BUILD_MESSAGE:
type: string
description: "Message to print in before_script"
default: "Default PRE BUILD message"
stages:
- pre_build
pre_build:
image: maven:3.8-openjdk-17
stage: pre_build
before_script:
- echo "$PRE_BUILD_MESSAGE"
script:
- mvn clean validate -DskipTests
only:
- merge_requests
In the target project:
include:
- project: my-group/general-ci-cd
ref: main
file: templates/pre-build.gitlab-ci.yml
inputs:
PRE_BUILD_MESSAGE: "Test message"
stages:
- pre_build
- package
package:
stage: package
before_script:
- echo "Building Java application"
script:
- mvn clean package -DskipTests
only:
- dev
- main
However, when I run the pipeline, I get this error:
`templates/pre-build.gitlab-ci.yml`: Given inputs not defined in the `spec` section of the included configuration file
I believe I defined the spec
correctly, but the error persists.
Is there something I’m missing about how inputs
and spec
should be structured?