This repository has been archived by the owner on Nov 15, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1
/
.gitlab-ci.yml
107 lines (96 loc) · 3.49 KB
/
.gitlab-ci.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
variables:
TREFLE_OLD_VERSION: "api-v0.7.14"
test:
image: python:3.6
cache:
paths:
- ~/.cache/pip/
before_script:
- python setup.py develop
- pip install -r requirements-dev.txt
stage: test
script:
- py.test -v --cov
- behave -D coverage-format=long
only:
- branches
- master
- /^api-v[0-9.ab]+$/
except:
- /^WIP-.*$/
sonarqube-check:
image:
name: sonarsource/sonar-scanner-cli:latest
variables:
SONAR_TOKEN: "${SONAR_TOKEN}"
SONAR_HOST_URL: "https://sonarqube.beta.pole-emploi.fr"
SONAR_USER_HOME: "${CI_PROJECT_DIR}/.sonar" # Defines the location of the analysis task cache
GIT_DEPTH: 0 # Tells git to fetch all the branches of the project, required by the analysis task
cache:
key: ${CI_JOB_NAME}
paths:
- .sonar/cache
stage: test
script:
- sonar-scanner -Dsonar.qualitygate.wait=true -Dsonar.projectKey=trefle
allow_failure: true
only:
- master
api publish:
image:
name: gcr.io/kaniko-project/executor:debug
entrypoint: [""]
stage: build
script:
- echo "{\"auths\":{\"$CI_REGISTRY\":{\"username\":\"$CI_REGISTRY_USER\",\"password\":\"$CI_REGISTRY_PASSWORD\"}}}" > /kaniko/.docker/config.json
- /kaniko/executor --context ${CI_PROJECT_DIR}/docker --dockerfile $CI_PROJECT_DIR/docker/dockerfile_trefle --build-arg TREFLE_VERSION=$CI_COMMIT_TAG --build-arg TREFLE_GIT=${CI_PROJECT_URL} --destination ${CI_REGISTRY_IMAGE}:${CI_COMMIT_TAG}
only:
- /^api-v[0-9.ab]+$/
- /^testing-api$/
deploy API to staging:
type: deploy
environment:
name: recette
url: http://trefle.beta.pole-emploi.fr
before_script:
- apt-get update -qq
- apt-get install -qq git
# Setup SSH deploy keys
- 'which ssh-agent || ( apt-get install -qq openssh-client )'
- eval $(ssh-agent -s)
- ssh-add <(echo "$SSH_PRIVATE_KEY")
- mkdir -p ~/.ssh
- '[[ -f /.dockerenv ]] && echo -e "Host *\n\tStrictHostKeyChecking no\n\n" > ~/.ssh/config'
script:
- ssh -o StrictHostKeyChecking=no gitlab@${STAGING_SERVEUR_IP} "cd /home/docker && VERSION=${CI_COMMIT_TAG} /bin/bash update_api.sh trefle && echo \"VERSION=${CI_COMMIT_TAG}\" | tee -a update.log >> .env"
only:
- /^api-v[0-9.ab]+$/
- /^testing-api$/
backoffice publish:
image:
name: gcr.io/kaniko-project/executor:debug
entrypoint: [""]
stage: build
script:
- echo "{\"auths\":{\"$CI_REGISTRY\":{\"username\":\"$CI_REGISTRY_USER\",\"password\":\"$CI_REGISTRY_PASSWORD\"}}}" > /kaniko/.docker/config.json
- /kaniko/executor --context ${CI_PROJECT_DIR}/docker --dockerfile ${CI_PROJECT_DIR}/docker/dockerfile_web --build-arg TREFLE_BACK_VERSION=${CI_COMMIT_TAG} --build-arg TREFLE_OLD_VERSION=${TREFLE_OLD_VERSION} --build-arg TREFLE_GIT=${CI_PROJECT_URL} --destination ${CI_REGISTRY_IMAGE}:${CI_COMMIT_TAG}
only:
- /^backoffice-v[0-9.ab]+$/
deploy Backoffice to staging:
type: deploy
environment:
name: recette
url: http://trefle.beta.pole-emploi.fr
before_script:
- apt-get update -qq
- apt-get install -qq git
# Setup SSH deploy keys
- 'which ssh-agent || ( apt-get install -qq openssh-client )'
- eval $(ssh-agent -s)
- ssh-add <(echo "$SSH_PRIVATE_KEY")
- mkdir -p ~/.ssh
script:
- ssh -o StrictHostKeyChecking=no gitlab@${STAGING_SERVEUR_IP} "cd /home/docker && BACK_VERSION=${CI_COMMIT_TAG} docker-compose up -d --no-deps web && echo \"BACK_VERSION=${CI_COMMIT_TAG}\" | tee -a .env >> update.log"
only:
- /^backoffice-v[0-9.ab]+$/
- /^testing-front$/