Expand or allow additional default stage names
Problem to solve
When implementing centralized templates which are utilized by many other Git repo's, users are forced to only use the default stage names of build, test and deploy. This limits the use of the central templates and only gives a user 3 parallel lanes to operate within
Further details
The following would be the simplest example:
Maven template to execute a build (note that this template is generic and can be used by any other project as long as the project which is going to use this template, passes in the necessary variables and secret Gitlab CI variables) Note that this template is named ".gitlab-maven-snapshot-build-template.yml"
variables:
MAVEN_SETTINGS: /usr/share/maven/ref/settings.xml
QUAY_URL: quay.repo.url
DOCKER_MAVEN_IMAGE: ${QUAY_URL}/solutions/maven:${MAVEN_IMAGE_VERS}
build-unit-test:
image: ${DOCKER_MAVEN_IMAGE}
stage: build
tags:
- openshift
artifacts:
paths:
- version.txt
untracked: true
expire_in: 4 hour
script:
- echo $(date +%Y%m%d%k%M%S) > version.txt
- mvn -s ${MAVEN_SETTINGS} versions:set -DnewVersion=${PROJECT_VERSION}.$(cat version.txt)
- mvn -s ${MAVEN_SETTINGS} clean
org.jacoco:jacoco-maven-plugin:prepare-agent
-Djacoco.destFile=$(pwd)/target/jacoco.exec deploy
-Dgit.branch=${CI_COMMIT_REF_NAME}
-Dgit.commit=${CI_COMMIT_SHA:0:8}
-DgitHash=${CI_COMMIT_SHA:0:8}
-DgitBranch=${CI_COMMIT_REF_NAME}
-DgitTag=${CI_COMMIT_TAG}
-DartifactoryUser=${ARTIFACTORY_API_USER}
-DartifactoryKey=${ARTIFACTORY_API_KEY_PRD}
- cat target/site/jacoco/index.html
allow_failure: false
when: always
The following is then a completely separate Git repo, that will then use the above template:
include:
- 'http://git.com/Team/raw/master/gitlab_CI_Templates/.gitlab-maven-snapshot-build-template.yml'
variables:
# Used in templates: Maven
PROJECT_VERSION: 4.3.0
As can be seen above, this keeps the "child" project which only has to "include" the template very small. Although, as can be seen in the actual template, the user must identify the stage of the template otherwise Git throws a error. If the stage is perhaps named "maven" for example, that would be fine, but the user is forced to place the stages element in there and then define the stage name "maven". By NOT defining the stage names, it keeps the stages very generic and easily ported to anyone who wants to use them and not have to code the stage.
(Include use cases, benefits, and/or goals)
Proposal
In order to allow the use of centralized CI templates, GitLab EE should be enhanced to allow more than the default 3 stages (build,test,deploy) to include possibly additional hard coded values, or even user customized values that will still allow the template stages to operate
What does success look like, and how can we measure that?
The acceptance criteria here would be that all templates being used, would only have to specify the stage they would run within. They would not have to depict the overall "stages" element and identify ALL stage names (If no way to measure success, link to an issue that will implement a way to measure this)