There are 3 stages - build, test and deploy in .gitlab-ci.yml
.
A nightly regression test stage needs to be run - well nightly
:)
Here's the relevant .gitlab-ci.yml
code:
stages: - build - test - deploy build_project: stage: build script: - cd ./some-dir - build-script.sh except: - tags #Run this only when say variable 'NIGHTLY_TEST == True'. But HOW? nightly_regression_test_project: stage: test script: - cd ./some-dir - execute test-script
Tagging daily to only
run test
stage is not preferable.
Any other idea?
except
and only
can specify variables that will trigger them.
You can use the following in your .gitlab-ci.yml:
build1: stage: build script: - echo "Only when NIGHTLY_TEST is false" except: variables: - $NIGHTLY_TEST test1: stage: test script: - echo "Only when NIGHTLY_TEST is true" only: variables: - $NIGHTLY_TEST
There's not currently a way to run a job depending on the environmental variables (you can always open a feature request!). You could use a simple Bash command to immediately exit if the environment variable doesn't exist, though.
Something like:
stages: - build - test - deploy build_project: stage: build script: - cd ./some-dir - build-script.sh except: - tags # Run this only when NIGHTLY_TEST environment variable exists. nightly_regression_test_project: stage: test script: - [ -z "$NIGHTLY_TEST" ] && exit 1; - cd ./some-dir - execute test-script
If the variable doesn't exist the tests that follow it won't run. Otherwise, they will.
Hope that helps!
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With