-
Notifications
You must be signed in to change notification settings - Fork 0
/
Jenkinsfile
74 lines (65 loc) · 2.55 KB
/
Jenkinsfile
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
def maindir = "."
pipeline {
agent any
stages {
stage('Pull Source Code') {
steps {
checkout scm
}
}
stage('Build Source Code') {
steps {
sh '''
id
java -version
./gradlew clean build -x test -x jacocoTestReport -x createDocument -x displaceDocument -x sonarqube
'''
}
}
stage('Docker image build & push') {
steps {
script {
withCredentials([usernamePassword(credentialsId: 'dockerHubRegistryCredential', usernameVariable: 'USERNAME', passwordVariable: 'PASSWORD')]) {
sh '''
NEW_TAG=$(git log -1 --pretty=%h)
dockerRepo="goharrm/offer-dev"
./gradlew jib \
-Djib.to.auth.username=${USERNAME} \
-Djib.to.auth.password=${PASSWORD} \
-Djib.to.image=${dockerRepo}:${NEW_TAG} \
-Djib.console='plain'
sleep 10
'''
}
}
}
}
stage('Argo Rollout Manifest Update') {
steps {
sshagent(credentials : ["offer-jenkins"]) {
sh '''
NEW_TAG=$(git log -1 --pretty=%h)
MAIN_PATH=`pwd`
if [ ! -e ~/offer-rollout/application-manifests ];
then
mkdir -p ~/offer-rollout
cd ~/offer-rollout
git clone [email protected]:price-offer/application-manifests.git
else
cd ~/offer-rollout/application-manifests
git pull origin main
fi
cd ~/offer-rollout/application-manifests
sed -i "s/offer-dev:.*\$/offer-dev:${NEW_TAG}/g" ./services/offer-be-rollout/rollout.yaml
git config --global user.email "[email protected]"
git config --global user.name "Jihun-Hwang"
git add ./services/offer-be-rollout/rollout.yaml
git commit -m "[FROM Jenkins] Container Image Tag was changed to ${NEW_TAG}"
git push
cd $MAIN_PATH
'''
}
}
}
}
}