If a task name matches a stage name, make the stage default to the task name
Summary
In .gitlab-ci.yml, it seems redundant to have to specify a stage when the task names themselves are self-descriptive. e.g.:
stages:
- build
- test
- release
- deploy
build:
stage: build
script:
- docker build -t $CONTAINER_TEST_IMAGE .
- docker push $CONTAINER_TEST_IMAGE
test:
stage: test
script:
- docker run $CONTAINER_TEST_IMAGE /script/to/run/tests
release:
stage: release
script:
- docker tag $CONTAINER_TEST_IMAGE $CONTAINER_RELEASE_IMAGE
- docker push $CONTAINER_RELEASE_IMAGE
only:
- master
deploy:
stage: deploy
script:
- ./deploy.sh
only:
- master
In the above example, I'd like to be able to leave out the stage, but if I do that, I believe it'll default to the test stage for every task.
Possible fixes
Rather than default the stage to test, check if the task name matches any of the stages first, and default to the matching name.
Edited by Jason Yavorsky