-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path.gitlab-ci.yml
166 lines (156 loc) · 4.27 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
156
157
158
159
160
161
162
163
164
165
166
image: node:8-stretch
stages:
- build
- test
- scan
- deploy
install:
stage: build
script:
- cd ITAC-Core
- npm install --only=production
tags:
- build
cache:
paths:
- ITAC-Core/node-modules
policy: push
install_preview:
stage: build
before_script:
- git config --global user.email "$GITLAB_USER_EMAIL"
- git config --global user.name "$GITLAB_USER_NAME"
script:
- git merge origin/develop --no-commit --no-ff
- cd ITAC-Core
- npm install --only=production
except:
- master
- develop
tags:
- build
test:
stage: test
script:
- cd ITAC-Core
- npm install
- npm test -- --reporter mocha-sonarqube-reporter --reporter-options output=./test-reports/unit.xml
tags:
- build
cache:
paths:
- ITAC-Core/node-modules
policy: pull-push
artifacts:
paths:
- ITAC-Core/test-reports
- ITAC-Core/coverage
coverage: '/^Statements\s*:\s*([^%]+)/'
test_preview:
stage: test
before_script:
- git config --global user.email "$GITLAB_USER_EMAIL"
- git config --global user.name "$GITLAB_USER_NAME"
script:
- git merge origin/develop --no-commit --no-ff
- cd ITAC-Core
- npm install
- npm test -- --reporter mocha-sonarqube-reporter --reporter-options output=./test-reports/unit.xml
except:
- master
- develop
tags:
- build
cache:
paths:
- ITAC-Core/node-modules
policy: pull
artifacts:
paths:
- ITAC-Core/test-reports
- ITAC-Core/coverage
test_sonar:
stage: scan
before_script:
- apt-get update -y
- apt-get install -y openjdk-8-jre-headless ca-certificates-java
script:
- cd ITAC-Core
- npm install
- npm run sonar-scanner -- -Dsonar.host.url=$SONAR_URL -Dsonar.projectKey=$CI_PROJECT_NAME.$CI_COMMIT_REF_SLUG -Dsonar.login=$SONAR_TOKEN -Dsonar.projectVersion=$CI_COMMIT_SHA -Dsonar.gitlab.url=$GITLAB_URL -Dsonar.gitlab.project_id=$CI_PROJECT_ID -Dsonar.gitlab.user_token=$SONAR_PLUGIN_TOKEN -Dsonar.gitlab.commit_sha=$CI_COMMIT_SHA -Dsonar.gitlab.ref_name=$CI_COMMIT_REF_NAME
only:
- master
- develop
tags:
- build
cache:
paths:
- ITAC-Core/node-modules
policy: pull
dependencies:
- test
test_sonar_preview:
stage: scan
before_script:
- apt-get update -y
- apt-get install -y openjdk-8-jre-headless ca-certificates-java
- git config --global user.email "$GITLAB_USER_EMAIL"
- git config --global user.name "$GITLAB_USER_NAME"
script:
- git merge origin/develop --no-commit --no-ff
- cd ITAC-Core
- npm install
- npm run sonar-scanner -- -Dsonar.host.url=$SONAR_URL -Dsonar.projectKey=$CI_PROJECT_NAME.develop -Dsonar.login=$SONAR_TOKEN -Dsonar.projectVersion=$CI_COMMIT_SHA -Dsonar.gitlab.url=$GITLAB_URL -Dsonar.gitlab.project_id=$CI_PROJECT_ID -Dsonar.gitlab.user_token=$SONAR_PLUGIN_TOKEN -Dsonar.gitlab.commit_sha=$CI_COMMIT_SHA -Dsonar.gitlab.ref_name=$CI_COMMIT_REF_NAME -Dsonar.analysis.mode=preview
except:
- master
- develop
tags:
- build
cache:
paths:
- ITAC-Core/node-modules
policy: pull
dependencies:
- test_preview
build:image:
variables:
IMAGE_TAG1: $CI_REGISTRY_IMAGE/linux:$CI_COMMIT_REF_SLUG
IMAGE_TAG2: $CI_REGISTRY_IMAGE/linux:$CI_COMMIT_SHA
IMAGE_TAG3: $CI_REGISTRY_IMAGE:linux
stage: deploy
image: docker
tags:
- build-docker-image
- dind1
script:
- docker build -t $IMAGE_TAG1 -t $IMAGE_TAG2 -t $IMAGE_TAG3 -f Dockerfile.linux .
- docker login -u gitlab-ci-token -p $CI_JOB_TOKEN $CI_REGISTRY
- docker push $IMAGE_TAG1
- docker push $IMAGE_TAG2
- docker push $IMAGE_TAG3
only:
- develop
when: manual
environment:
name: staging
build:image:stable:
variables:
IMAGE_TAG1: $CI_REGISTRY_IMAGE/linux:$CI_COMMIT_REF_SLUG
IMAGE_TAG2: $CI_REGISTRY_IMAGE/linux:$CI_COMMIT_SHA
IMAGE_TAG3: $CI_REGISTRY_IMAGE:stable-linux
stage: deploy
image: docker
tags:
- build-docker-image
- dind1
script:
- docker build -t $IMAGE_TAG1 -t $IMAGE_TAG2 -t $IMAGE_TAG3 -f Dockerfile.linux .
- docker login -u gitlab-ci-token -p $CI_JOB_TOKEN $CI_REGISTRY
- docker push $IMAGE_TAG1
- docker push $IMAGE_TAG2
- docker push $IMAGE_TAG3
only:
- master
when: manual
environment:
name: staging