.gitlab-ci.yml 1.9 KB
Newer Older
Jonas Waeber's avatar
Jonas Waeber committed
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
variables:
  DOCKER_TLS_CERTDIR: ""

stages:
  - test
  - publish

test:
  stage: test
  image: gradle:6.3-jdk8
  tags:
    - mbr
  script:
    - gradle --no-daemon --no-scan --no-build-cache test --fail-fast --tests "org.memobase.Test"


.build-image:
  stage: publish
  image: docker:stable
  services:
    - docker:dind
  script:
    - docker login -u "$REGISTRY_USER" -p "$REGISTRY_PASSWORD" "$REGISTRY"
    - docker build --pull -t "$IMAGE_TAG" -f "$DOCKERFILE" .
    - docker push "$IMAGE_TAG"
    - docker logout

build-tagged-image:
  extends: .build-image
  variables:
    IMAGE_TAG: "$CI_REGISTRY_IMAGE:$CI_COMMIT_TAG"
    REGISTRY_PASSWORD: "$CI_REGISTRY_PASSWORD"
    REGISTRY_USER: "$CI_REGISTRY_USER"
    REGISTRY: "$CI_REGISTRY"
    DOCKERFILE: "Dockerfile"
  only:
    - tags

build-latest-image:
  extends: .build-image
  variables:
    IMAGE_TAG: "$CI_REGISTRY_IMAGE:latest"
    REGISTRY_PASSWORD: "$CI_REGISTRY_PASSWORD"
    REGISTRY_USER: "$CI_REGISTRY_USER"
    REGISTRY: "$CI_REGISTRY"
    DOCKERFILE: "Dockerfile"
  only:
    - master

build-feature-branch-image:
  extends: .build-image
  variables:
    IMAGE_TAG: "$CI_REGISTRY_IMAGE:$CI_COMMIT_REF_NAME"
    REGISTRY_PASSWORD: "$CI_REGISTRY_PASSWORD"
    REGISTRY_USER: "$CI_REGISTRY_USER"
    REGISTRY: "$CI_REGISTRY"
    DOCKERFILE: "Dockerfile"
  except:
    - master
    - tags

test-chart:
  stage: test
  image: dtzar/helm-kubectl:3.2.0
  tags:
    - mbr
  script:
    - helm lint chart/

publish-chart:
  stage: publish
  image: dtzar/helm-kubectl:3.2.0
  tags:
    - mbr
  script:
    - export HELM_EXPERIMENTAL_OCI=1
    - helm registry login -u "$CI_REGISTRY_USER" -p "$CI_REGISTRY_PASSWORD" "$CI_REGISTRY"
    - ./insert_chart_versions.sh
    - helm chart save chart/ "$CI_REGISTRY/$CI_PROJECT_PATH:$CI_COMMIT_TAG-chart"
    - helm chart push "$CI_REGISTRY/$CI_PROJECT_PATH:$CI_COMMIT_TAG-chart"
    - helm registry logout "$CI_REGISTRY"
  only:
    - tags