Commit 73f5f1bf authored by Alex Iribarren's avatar Alex Iribarren
Browse files

Use include in .gitlab-ci.yml

parent 24382316
Pipeline #544775 passed with stages
in 1 minute and 11 seconds
---
variables:
VAULT_VERSION: '0.11.1'
NOMAD_VERSION: '0.8.4'
NOMAD_ADDR: "https://${CLUSTER_ADDR}:4646"
VAULT_ADDR: "https://${CLUSTER_ADDR}:8200"
include: 'https://gitlab.cern.ch/linuxsupport/cronjobs/base/raw/master/gitlab-ci.yml'
before_script:
- if [[ $CI_COMMIT_REF_NAME == 'master' || -n ${CI_COMMIT_TAG+x} ]]; then PREFIX='prod'; else PREFIX='dev'; fi
- set -a
- source ${PREFIX}.variables.sh
stages:
- prepare
- build
- deploy_test
- deploy
- cleanup
build_hello:
stage: build
......@@ -25,42 +10,3 @@ build_hello:
variables:
CONTEXT_DIR: hello
TO: $CI_REGISTRY_IMAGE/hello:$CI_COMMIT_REF_NAME
.nomad_deps_template: &nomad_deps
curl https://releases.hashicorp.com/vault/${VAULT_VERSION}/vault_${VAULT_VERSION}_linux_amd64.zip -o /tmp/vault.zip &&
curl https://releases.hashicorp.com/nomad/${NOMAD_VERSION}/nomad_${NOMAD_VERSION}_linux_amd64.zip -o /tmp/nomad.zip &&
unzip /tmp/vault.zip -d /usr/local/bin/ &&
unzip /tmp/nomad.zip -d /usr/local/bin/ &&
vault read nomad/creds/submitjobs -format=json > token.json &&
export `jq -r '"NOMAD_TOKEN=" + .data.secret_id' token.json` &&
if [ -z ${CI_COMMIT_TAG+x} ]; then export FORCE_PULL="true"; else export FORCE_PULL="false"; fi
deploy_test:
stage: deploy_test
dependencies: []
script:
- *nomad_deps
- for j in *.nomad; do echo -e "\n${j}:"; nomad job validate <(envsubst < $j); done
- for j in *.nomad; do echo -e "\n${j}:"; (nomad job plan -verbose <(envsubst < $j) || [[ $? -eq 0 || $? -eq 1 ]]) || break; done
# plan returns 0 or 1 on success
deploy:
stage: deploy
dependencies:
- deploy_test
script:
- *nomad_deps
- for j in *.nomad; do echo -e "\n${j}:"; nomad job run <(envsubst < $j); done
stop_testing:
stage: cleanup
dependencies:
- deploy
script:
- *nomad_deps
- JOB_PREFIX="`source dev.variables.sh && echo $JOB_PREFIX`"
- for j in *.nomad; do JOB=`grep task <(envsubst < $j) | sed 's/.*"\([^"]*\)".*/\1/'`; echo -e "\nDeleting job ${JOB}:"; nomad job stop -verbose ${JOB} || true; done
only:
- tags
- master
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment