-
Notifications
You must be signed in to change notification settings - Fork 0
/
.gitlab-ci.yml
88 lines (82 loc) · 1.75 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
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
image: maven:3.8.3-jdk-11
variables:
MAVEN_LOCAL_REPOSITORY: "-Dmaven.repo.local=./.m2/repository"
stages:
- build
- build_deploy_nexus
- deploy_dockerhub
- deploy_prod
build:
stage: build
only:
- merge_requests
- cicd
- test_cicd
except:
- tags
script:
- mvn --settings maven-settings.xml clean package
- ls -la ./impl/target
artifacts:
paths:
- impl/target/*.jar
cache:
paths:
- ./impl/target
- ./domain/target
build_deploy_nexus:
stage: build_deploy_nexus
only:
- master
- develop
- cicd
except:
- tags
script:
- mvn --settings maven-settings.xml clean deploy
- ls -la ./impl/target
artifacts:
paths:
- impl/target/*.jar
cache:
paths:
- ./impl/target
- ./domain/target
build_and_push_image:
image: docker:19.03.12
stage: deploy_dockerhub
only:
- develop
- main
- cicd
- test_cicd
except:
- tags
before_script:
- docker logout
- docker login -u $DOCKERHUB_USER -p $DOCKERHUB_PASS https://index.docker.io/v1/
script:
- docker build -f Dockerfile --platform linux/arm64/v8 -t $BACK_IMAGE .
- docker push $BACK_IMAGE
artifacts:
paths:
- impl/target/*.jar
deploy_prod_server:
stage: deploy_prod
only:
- develop
- main
- cicd
- test_cicd
except:
- tags
before_script:
- which ssh-agent || ( apt-get update -y && apt-get install openssh-client -y )
- eval $(ssh-agent -s)
- echo "$SSH_PRIVATE_KEY" | ssh-add -
- mkdir -p ~/.ssh
- chmod 700 ~/.ssh
- ssh-keyscan $PROD_HOST >> ~/.ssh/known_hosts
- chmod 644 ~/.ssh/known_hosts
script:
- ssh $PROD_USER@$PROD_HOST "kubectl rollout restart -n $NAMESPACE deployment $DEPLOYMENT_NAME"