-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path.gitlab-ci.yml
70 lines (64 loc) · 2.36 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
stages:
- lint
- build
- test
- publish
default:
tags:
- aws_run_k8s_intel
variables:
MTR_REGISTRY: mtr.devops.telekom.de
MTR_REGISTRY_IMAGE: mtr.devops.telekom.de/secureops/safescarf-connector
README_FILE: README.md
SAFESCARF_HOST: https://dt-sec.safescarf.pan-net.cloud/
lint_readme:
stage: lint
image: dockerhub.devops.telekom.de/alpine:latest
rules:
# don't run on release pipelines when 'X.Y.Z' pattern is created
- if: '$CI_COMMIT_TAG =~ /^\d+\.\d+\.\d+$/'
when: never
script:
- apk --no-cache add nodejs npm
- npm install -g markdownlint-cli
- markdownlint -c .linter-config/markdownlint-cli-config.yml $README_FILE
build_image:
stage: build
image:
name: gcr.io/kaniko-project/executor:debug
entrypoint: [""]
rules:
- if: '$CI_COMMIT_REF_PROTECTED == "true"'
script:
- mkdir -p /kaniko/.docker
- echo "{\"auths\":{\"${MTR_REGISTRY}\":{\"auth\":\"$(printf "%s:%s" "${MTR_REGISTRY_USER}" "${MTR_REGISTRY_PASSWORD}" | base64 | tr -d '\n')\"}}}" > /kaniko/.docker/config.json
- /kaniko/executor
--context "${CI_PROJECT_DIR}"
--dockerfile "${CI_PROJECT_DIR}/Dockerfile"
--destination "${MTR_REGISTRY_IMAGE}:$CI_COMMIT_SHORT_SHA"
#scan-docker-image-trivy:
# stage: test
# image:
# name: registry.safescarf.pan-net.cloud/trivy
# entrypoint: [""]
# rules:
# - if: '$CI_COMMIT_REF_PROTECTED == "true"'
# script:
# - ci-connector --version
# - time trivy image --format json --output "$CI_PROJECT_DIR/trivy-container-scanning-report.json" "${MTR_REGISTRY_IMAGE}:$CI_COMMIT_SHORT_SHA"
# - ci-connector upload-scan --scanner 'Trivy Scan' -e "${SAFESCARF_ENG_ID}" -f "$CI_PROJECT_DIR/trivy-container-scanning-report.json" --token "$SAFESCARF_API_TOKEN"
publish_release:
stage: publish
image:
name: gcr.io/kaniko-project/executor:debug
entrypoint: [""]
rules:
# Runs only when a tag with 'X.Y.Z' pattern is created
- if: '$CI_COMMIT_TAG =~ /^\d+\.\d+\.\d+$/'
script:
- mkdir -p /kaniko/.docker
- echo "{\"auths\":{\"${MTR_REGISTRY}\":{\"auth\":\"$(printf "%s:%s" "${MTR_REGISTRY_USER}" "${MTR_REGISTRY_PASSWORD}" | base64 | tr -d '\n')\"}}}" > /kaniko/.docker/config.json
- /kaniko/executor
--context "${CI_PROJECT_DIR}"
--dockerfile "${CI_PROJECT_DIR}/Dockerfile"
--destination "${MTR_REGISTRY_IMAGE}:${CI_COMMIT_TAG}"