.gitlab-ci.yml 1.24 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
stages:
  - test
  - publish

test:
  stage: test
  image: openjdk:8
  script:
    - ./gradlew --no-daemon test --fail-fast --tests "org.memobase.Tests"


.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