I have what I would call a generic pipeline in a specific project, and every other project that needs this pipeline to build their Docker image just include this pipeline to use it. This is something that I guess everyone pretty much do.
When including this pipeline, you need to set a few variables for the pipeline included to work. At the moment, these variables are defined in the project where the generic pipeline is included. The variables defined are of type dropdown list or free form values, here is how I include the generic pipeline and set the variables :
variables: DOCKER_IMAGE_NAME: value: "" description: "REQUIRED: Provide the name of the Docker image to build" USED_BY_CI: value: "" description: "OPTIONAL: Select the 'CICD' value if the image that is built will be used in CI/CD pipelines, otherwise leave it empty. This will be only appended when pushing into Gitlab registry" options: - "CICD" - "" DOCKERFILE_PATH: value: "Dockerfile" description: "REQUIRED: Select the correct Dockerfile to build the image from. By default the one named 'Dockerfile' will be used" CUSTOM_TAG_VALUE: value: "" description: "OPTIONAL: If the Dockerfile used to build the image is different from the default one, you can append here a specific tag that will be used in the name of the container built. NOTE: Do not use space between words! Use a '-' (dash)" REGISTRY_TARGET: value: "Gitlab" description: "REQUIRED: Select the container registry target, to where the built Docker image will be stored" options: - "ECR" - "Gitlab" ECR_REPOSITORY_NAME: value: "php" description: "ONLY IF ECR REGISTRY IS USED: If the target container registry is ECR, please specify the name of the repository where the image should be stored in ECR" options: - "php" include: project: system/pipeline-generic ref: main file: - docker-image-builder-kaniko.yml
What I would like to do, is to have those variables defined at the generic pipeline level, so that every project can inherit them from the include keyword. This would help implement new features much easier, and not have to edit 20 projects to define a new variables needed by the generic pipeline to work.
It doesn’t seem at the moment possible to do that, as implementing those variables like written above in the generic pipeline, are not inherited through the include.
Does anyone has a solution to this? Is this even possible at the moment?
When I start a pipeline with the variables defined at the generic pipeline level, I do not have any variables shown :
But when the variables are defined in the project level it of course does work :
My Gitlab version is 16.1.2
If you need more information, feel free to ask, and thanks for the help!