diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index bcb4edc..964d399 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -131,6 +131,8 @@ test_e2e: artifacts: false - test_e2e script: + - export NOMAD_NAMESPACE="$NOMAD_SLUG" + - nomad namespace apply $NOMAD_NAMESPACE # Only replace set env vars - envsubst "$(env | sed -e 's/=.*//' -e 's/^/\$/g')" < ci/api.tpl.nomad > ci/api.nomad # Make sure to set NOMAD_ADDR, NOMAD_SKIP_VERIFY and NOMAD_TOKEN env vars in CI settings appropriately @@ -167,7 +169,10 @@ stop_review: variables: GIT_STRATEGY: none script: - - nomad stop $NOMAD_SLUG + - export NOMAD_NAMESPACE="$NOMAD_SLUG" + # Stop all jobs before deleting the namespace + - nomad job status | cut -d" " -f1 | tail -n +2 | xargs -n1 nomad stop + - nomad namespace delete $NOMAD_NAMESPACE environment: name: $CI_COMMIT_REF_SLUG action: stop diff --git a/ci/api.tpl.nomad b/ci/api.tpl.nomad index ef680dd..a9c145b 100644 --- a/ci/api.tpl.nomad +++ b/ci/api.tpl.nomad @@ -1,5 +1,6 @@ job "${NOMAD_SLUG}" { datacenters = ["dc1"] + namespace = "${NOMAD_NAMESPACE}" group "api" { count = 1 @@ -63,6 +64,7 @@ job "${NOMAD_SLUG}" { env { POSEIDON_SERVER_ADDRESS = "${POSEIDON_LISTEN_ADDRESS}" POSEIDON_NOMAD_ADDRESS = "${NOMAD_SERVER_HOST}" + POSEIDON_NOMAD_NAMESPACE = "${NOMAD_NAMESPACE}" } resources {