-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path.gitlab-ci.yml
53 lines (48 loc) · 1.23 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
before_script:
- export GRADLE_USER_HOME=`pwd`/.gradle
cache:
paths:
- .gradle/wrapper
- .gradle/caches
stages:
- build
- package
- release
build-jar:
image: gradle:7.5.1-jdk17
stage: build
script: "./gradlew build"
artifacts:
paths:
- build/libs/app.jar
package-docker-default:
stage: package
image: docker:stable-dind
rules:
- if: '$CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH'
services:
- name: docker:stable-dind
alias: docker
needs:
- job: build-jar
artifacts: true
script:
- ls -halt
- docker login -u $CI_REGISTRY_USER -p $CI_REGISTRY_PASSWORD $CI_REGISTRY
- docker build --build-arg JAR_SOURCE_PATH="build/libs/app.jar" --tag "${CI_REGISTRY_IMAGE}" .
- docker push $CI_REGISTRY_IMAGE
package-docker-release:
stage: release
services:
- name: docker:stable-dind
alias: docker
rules:
- if: $CI_COMMIT_TAG
needs:
- job: build-jar
artifacts: true
script:
- ls -halt
- docker login -u $CI_REGISTRY_USER -p $CI_REGISTRY_PASSWORD $CI_REGISTRY
- docker build --build-arg JAR_SOURCE_PATH="build/libs/app.jar" --tag "${CI_REGISTRY_IMAGE}" --tag "${CI_REGISTRY_IMAGE}:${CI_COMMIT_TAG}" .
- docker push $CI_REGISTRY_IMAGE