Skip to content
Snippets Groups Projects
Commit 37e6b6f1 authored by Benguria Elguezabal, Gorka's avatar Benguria Elguezabal, Gorka
Browse files

y1 baseline

parent 31f707d8
No related branches found
No related tags found
No related merge requests found
stages:
- build
- deploy
- push
- promote
- stop
variables:
GIT_SUBMODULE_STRATEGY: normal
.common_variables:
variables:
TZ: Madrid
SERVER_HOST: piacere.esilab.org
INFLUXD_BUCKET: bucket
INFLUXD_ORG: piacere
INFLUXD_USERNAME: piacere
GRAFANA_ADMIN_USER: piacere
SMTP_USER_EMAIL: piacere@esilab.org
GRAFANA_NOTIFICATION_PRIMARY_EMAIL: piacere@esilab.org
PROJECT_NAME: piacere-monitoring
.any_branch:
extends:
- .common_variables
variables:
# these variables take precedence over .env
# CERTIFICATE_SIGNING_KEY_PASSPHRASE defined in variables at settings/ci_cd
# SERVER_HOST defined in variables at settings/ci_cd
HTTPS_PORT: 8443
COMPOSE_FILE: "docker-compose.yaml"
COMPOSE_PROJECT_NAME: piacere-monitoring-any-branch
COMPOSE_PROJECT_VERSION: test
ADD_DEFAULT_CA: "true"
except:
- master
- develop
- pilots
tags:
- piacere-monitoring
- docker
- docker-compose
- any-branch
.develop:
extends:
- .common_variables
variables:
# these variables take precedence over .env
# CERTIFICATE_SIGNING_KEY_PASSPHRASE defined in variables at settings/ci_cd
# SERVER_HOST defined in variables at settings/ci_cd
HTTPS_PORT: 8443
COMPOSE_FILE: "docker-compose.yaml:docker-compose-expose.yaml:docker-compose-dev.yaml:docker-compose-dev-expose.yaml"
COMPOSE_PROJECT_NAME: piacere-monitoring-develop
COMPOSE_PROJECT_VERSION: develop
ADD_DEFAULT_CA: "true"
only:
- develop
tags:
- piacere-monitoring
- docker
- docker-compose
- develop
.master:
extends:
- .common_variables
variables:
# these variables take precedence over .env
# CERTIFICATE_SIGNING_KEY_PASSPHRASE defined in variables at settings/ci_cd
# SERVER_HOST defined in variables at settings/ci_cd
ADD_DEFAULT_CA: "true"
only:
- master
tags:
- piacere-monitoring
- docker
- docker-compose
- master
.build:
script:
- echo "build images"
- docker-compose build --parallel
.deploy:
script:
- echo "Deploy to the environment"
- docker-compose up -d
.push:
script:
- echo "pull base images from cache"
- docker login $DOCKER_REGISTRY -u $DOCKER_REGISTRY_USERNAME -p $DOCKER_REGISTRY_APIKEY
- echo "Deploy to the environment"
- docker-compose push
.stop:
variables:
GIT_STRATEGY: none
script:
- echo "Stops the environment"
- docker-compose down --remove-orphans
build_any_branch:
stage: build
extends:
- .any_branch
- .build
deploy_any_branch:
stage: deploy
extends:
- .any_branch
- .deploy
stop_any_branch:
variables:
COMPOSE_FILE: "docker-compose.yaml:docker-compose-tests.yaml"
stage: stop
extends:
- .any_branch
- .stop
build_develop:
stage: build
extends:
- .develop
- .build
deploy_develop:
stage: deploy
extends:
- .develop
- .deploy
environment:
name: develop
url: https://$SERVER_HOST:8443
on_stop: stop_develop
stop_develop:
variables:
COMPOSE_FILE: "docker-compose.yaml:docker-compose-expose.yaml:docker-compose-dev.yaml:docker-compose-dev-expose.yaml"
stage: stop
extends:
- .develop
- .stop
environment:
name: develop
action: stop
when: manual
build_master:
stage: build
extends:
- .master
- .build
push_master_images_to_artifactory:
stage: push
extends:
- .master
- .push
when: manual
deploy_master:
stage: deploy
extends:
- .master
- .deploy
environment:
name: master
url: https://$SERVER_HOST
on_stop: stop_master
stop_master:
stage: stop
extends:
- .master
- .stop
environment:
name: master
action: stop
when: manual
promote_to_master:
extends:
- .develop
stage: promote
when: manual
script:
- echo "in case custom-origin remote exist remove it"
- git remote rm custom-origin > /dev/null 2>&1 || true
- echo "checking the username"
- >
if ( [ -z "$AT" ] || [ "$AT" == "undefined" ] ) && ( ( [ -z "$USER" ] || [ "$USER" == "undefined" ] ) || ( [ -z "$PASSWORD" ] || [ "$PASSWORD" == "undefined" ] ) ); then
echo "This job requires credentials to be added as variables (key/Value) in the job detail page before clicking the triggering this manual action button. Credentials can be provided in to ways: With an AT (access token) or with a USER and a PASSWORD. AT can be defined in your profile access tokens page https://git.code.tecnalia.com/-/profile/personal_access_tokens it must have read_repository and write_repository rights. USER and PASSWORD are those that you use to access gitlab. AT has prececedence over USER/PASSWORD."
exit 1
fi
- >
if [ ! -z "$AT" ]; then
export USER="oauth"
export PASSWORD="$AT"
fi
- echo "url encode credentials"
- export USER=$(python3 -c "import urllib.parse; print (urllib.parse.quote('''$USER'''))")
- export PASSWORD=$(python3 -c "import urllib.parse; print (urllib.parse.quote('''$PASSWORD'''))")
- git remote add custom-origin https://$USER:$PASSWORD@${CI_PROJECT_URL:8}
- git fetch custom-origin develop --depth=1
- git fetch custom-origin master --depth=1
- git checkout master
- git reset --hard custom-origin/develop
- git push custom-origin -f
- git remote rm custom-origin > /dev/null 2>&1 || true
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment