-
Notifications
You must be signed in to change notification settings - Fork 3
/
.gitlab-ci.yml
155 lines (143 loc) · 3.98 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
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
stages:
- test
- build image
- static scans
- trigger deploy
- publish pages
variables:
MYSQL_ROOT_PASSWORD: "root"
MYSQL_DATABASE: "ota_treehub"
MYSQL_USER: "treehub"
MYSQL_PASSWORD: "treehub"
# VAULT_ADDR: defined in GitLab variables
# The same image have to be used by test and code coverage jobs:
TEST_IMAGE: advancedtelematic/gitlab-jobs:0.2.5
TEST_IMAGE_SONAR: advancedtelematic/gitlab-jobs-sonar:0.0.3
default:
services:
- name: mariadb:10.4.31
alias: db
command:
- --character-set-server=utf8
- --collation-server=utf8_unicode_ci
- --max_connections=1000
test:
stage: test
except:
refs:
- deploy/sit
image: $TEST_IMAGE
variables:
DB_URL: "jdbc:mariadb://db:3306/ota_treehub"
before_script:
- echo "GRANT ALL PRIVILEGES ON \`ota\_treehub%\`.* TO 'treehub'@'%'; FLUSH PRIVILEGES;" > db_user.sql
- mysqladmin ping --protocol=TCP -h db -P 3306 -u root -proot
- mysql -v -h db -u root -proot < db_user.sql
script:
- sbt -sbt-dir ./.sbt -ivy ./.ivy2 -J-Xmx1G -J-XX:MaxPermSize=256m -J-XX:ReservedCodeCacheSize=128m clean coverage ut:test
artifacts:
paths:
- "target/scala-*/scoverage-data"
- "target/scala-*/src_managed"
- "target/scala-*/classes"
cache:
paths:
- .ivy2/
- .sbt/
code coverage:
extends: .report_scala_coverage
except:
refs:
- deploy/sit
allow_failure: true
image: $TEST_IMAGE_SONAR
export docker credentials:
extends: .export_docker_credentials
stage: test
rules:
- if: '$CI_COMMIT_BRANCH != "master"'
when: never
- if: '$CI_PIPELINE_SOURCE == "schedule"'
when: never
- when: on_success
build docker image:
stage: build image
rules:
- if: '$CI_COMMIT_BRANCH != "master"'
when: never
- if: '$CI_PIPELINE_SOURCE == "schedule"'
when: never
- when: on_success
variables:
DOCKER_TLS_CERTDIR: ""
DOCKER_HOST: tcp://docker:2375
image: advancedtelematic/gitlab-jobs:0.3.3
services:
- docker:19.03.12-dind
script:
- gitlab-docker-login $VAULT_ADDR
- sbt -x -sbt-dir ./.sbt -ivy ./.ivy2 -batch docker:publish -J-Xmx1G -J-XX:ReservedCodeCacheSize=128m -Dsbt.log.noformat=true
- docker tag advancedtelematic/treehub:${CI_COMMIT_SHA} hcr.data.here.com/ota_saas/treehub:${CI_COMMIT_SHA}
- docker push hcr.data.here.com/ota_saas/treehub:${CI_COMMIT_SHA}
artifacts:
paths:
- "target/docker/stage/Dockerfile"
cache:
paths:
- .ivy2/
- .sbt/
container_scanning:
stage: static scans
rules:
- if: '$CI_COMMIT_BRANCH != "master"'
when: never
- if: '$CI_PIPELINE_SOURCE == "schedule"'
when: never
- when: on_success
variables:
GIT_STRATEGY: fetch
CS_SEVERITY_THRESHOLD: High
CI_APPLICATION_REPOSITORY: hcr.data.here.com/ota_saas/treehub
DOCKERFILE_PATH: target/docker/stage/Dockerfile
DOCKER_USER: $HCR_REGISTRY_USER
DOCKER_PASSWORD: $HCR_REGISTRY_PASSWORD
trigger dev deploy:
stage: trigger deploy
rules:
- if: '$CI_COMMIT_BRANCH != "master"'
when: never
- if: '$CI_PIPELINE_SOURCE == "schedule"'
when: never
- when: on_success
variables:
ENV: "dev"
NEW_TAG: $CI_COMMIT_SHA
SERVICE: $CI_PROJECT_NAME
CREATE_COMMIT: "true"
UPSTREAM_COMMIT_MESSAGE: $CI_COMMIT_MESSAGE
trigger:
project: OLP/EDGE/OTA/infra/deployment-descriptors
branch: master
trigger sit deploy:
stage: trigger deploy
except:
- schedules
only:
- deploy/sit
variables:
ENV: "sit"
NEW_TAG: $CI_COMMIT_SHA
SERVICE: $CI_PROJECT_NAME
CREATE_COMMIT: "true"
UPSTREAM_COMMIT_MESSAGE: $CI_COMMIT_MESSAGE
trigger:
project: OLP/EDGE/OTA/infra/deployment-descriptors
branch: master
include:
- template: SAST.gitlab-ci.yml
- template: Security/Container-Scanning.gitlab-ci.yml
- project: "poit/spc/be/prodsec-secret-detection"
file: "ITT-Secret-Detection.gitlab-ci.yml"
- project: olp/edge/ota/infra/security
ref: v0.1.1
file: /shared.yaml