-
Notifications
You must be signed in to change notification settings - Fork 7
/
.gitlab-ci.yml
64 lines (58 loc) · 1.64 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
image: registry.gitlab.com/knmi/shs/knmi-build-image:latest
variables:
DOCKER_DRIVER: overlay2
DOCKER_HOST: tcp://localhost:2375
REGION: eu-west-1
services:
- docker:dind
stages:
- test
- compile
- build
test:
stage: test
image: maven:3-jdk-8-alpine
variables:
MAVEN_OPTS: "-Dmaven.repo.local=.m2"
cache:
paths:
- .m2/
script:
- mvn clean test
compile:
stage: compile
image: maven:3-jdk-8-alpine
variables:
MAVEN_OPTS: "-Dmaven.repo.local=.m2
-Dmaven.test.skip=true"
cache:
paths:
- .m2/
script:
- mvn clean package
- cp ./target/geoweb-backend-*.jar geoweb-backend.jar
artifacts:
paths:
- geoweb-backend.jar
build:
stage: build
image: registry.gitlab.com/knmi/shs/knmi-build-image:latest
variables:
IMAGE_TAG: 1.0.$CI_COMMIT_SHORT_SHA.$CI_PIPELINE_ID
REPO_NAMESPACE: knmi
REPOSITORY: geoweb-backend
ECR_REGISTRY_IMAGE: $BUILD_ACCOUNT_ID.dkr.ecr.$REGION.amazonaws.com/$REPO_NAMESPACE/$REPOSITORY
before_script:
- docker login -u gitlab-ci-token -p $CI_JOB_TOKEN registry.gitlab.com
script:
- docker build -t $CI_REGISTRY_IMAGE:latest .
- docker push $CI_REGISTRY_IMAGE:latest
- docker tag $CI_REGISTRY_IMAGE:latest $CI_REGISTRY_IMAGE:$IMAGE_TAG
- docker push $CI_REGISTRY_IMAGE:$IMAGE_TAG
- "sh /build-utils/ecr.sh -n $REPO_NAMESPACE -r $REPOSITORY -a $DTA_GEOWEB_ACCOUNT_ID,$PRD_GEOWEB_ACCOUNT_ID"
- $(aws ecr get-login --no-include-email --region $REGION)
- docker tag $CI_REGISTRY_IMAGE:latest $ECR_REGISTRY_IMAGE:$IMAGE_TAG
- docker push $ECR_REGISTRY_IMAGE:$IMAGE_TAG
only:
refs:
- master