We have a GitLab Ci/CD .gitlab-ci.yaml file that builds software packages. This .gitlab-ci.yaml has a variable that determines which operating system release the package should be built for. We would like to use the include keyword in other GitLab projects to include this .gitlab-ci.yaml to allow us to build packages. We want to build this package for multiple operating system releases. However, we cannot as GitLab does not allow us to include the same file twice. Is there another way to do this?
To see this more concretely, assume the .gitlab-ci.yaml file we want to include in other projects is this:
# common/gitlab-templates/.gitlab-ci.yaml
variables:
OS_RELEASE: 10.0
build-package:
script: echo "building for $OS_RELEASE"
In another GitLab project we would like to do something like this:
# Build for version 8.0
include:
- project: 'common/gitlab-templates'
file: '.gitlab-ci.yml'
variables:
OS_RELEASE: 8.0
# Build for version 9.0
include:
- project: 'common/gitlab-templates'
file: '.gitlab-ci.yml'
variables:
OS_RELEASE: 9.0
# Build for version 10.0
include:
- project: 'common/gitlab-templates'
file: '.gitlab-ci.yml'
variables:
OS_RELEASE: 10.0
However, the above is not valid .gitlab-ci.yaml syntax.
How do we get around this?