-
Notifications
You must be signed in to change notification settings - Fork 0
/
.gitlab-ci.yml
36 lines (32 loc) · 1.13 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
stages:
- build
- test
services:
- docker:dind
build:
image: docker:latest
stage: build
before_script:
- PROJECT_API_URL=$CI_API_V4_URL/projects/$CI_PROJECT_ID
- export BASE_NAME=${CI_REGISTRY}/${CI_PROJECT_NAMESPACE}/${CI_PROJECT_NAME}
- export IMAGE_NAME=${BASE_NAME}:${CI_COMMIT_TAG}
script:
- docker login -u "$CI_REGISTRY_USER" -p "$CI_REGISTRY_PASSWORD" $CI_REGISTRY
- docker build --progress plain --pull -t "${IMAGE_NAME}" .
- |
if [ ! $CI_PIPELINE_SOURCE == "web" ]; then
echo Update 'latest' tag
docker tag "${IMAGE_NAME}" "${BASE_NAME}:latest"
fi
- docker image push --all-tags "${BASE_NAME}"
rules:
- if: '$CI_PIPELINE_SOURCE == "web" && $CI_COMMIT_TAG'
- if: $CI_COMMIT_TAG
include:
- template: Jobs/Container-Scanning.gitlab-ci.yml
container_scanning:
rules:
- if: '$CI_PIPELINE_SOURCE == "web" && $CI_COMMIT_TAG'
- if: $CI_COMMIT_TAG
variables:
CS_IMAGE: ${CI_REGISTRY}/${CI_PROJECT_NAMESPACE}/${CI_PROJECT_NAME}:${CI_COMMIT_TAG}