-
Notifications
You must be signed in to change notification settings - Fork 2
/
Jenkinsfile
65 lines (55 loc) · 1.98 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
pipeline{
agent any
tools {
gradle 'Gradle-7.1.1'
}
environment {
AWS_S3_ACCESS_KEY = credentials('AWS_S3_ACCESS_KEY')
AWS_S3_SECRET_KEY = credentials('AWS_S3_SECRET_KEY')
AWS_S3_REGION_KEY = credentials('AWS_S3_REGION_KEY')
}
stages {
stage("Build"){
steps{
sh 'chmod +x gradlew'
sh './gradlew cleanQuerydslSourcesDir'
sh './gradlew bootJar'
echo '------ Run spring boot FINISH ------'
}
}
stage('ImagePush'){
steps{
sh 'rm ~/.dockercfg || true'
sh 'rm ~/.docker/config.json || true'
script{
docker.withRegistry('https://758812638430.dkr.ecr.ap-northeast-2.amazonaws.com/auction', 'ecr:ap-northeast-2:ecr-credentials'){
def image = docker.build("758812638430.dkr.ecr.ap-northeast-2.amazonaws.com/auction")
image.push("${env.BUILD_NUMBER}")
image.push('latest')
}
echo '------Build and Push image FINISH ------'
}
}
}
stage('Deploy'){
steps{
script{
withAWS(credentials:"AWS_CREDENTIALS", region: 'ap-northeast-2') {
sh 'aws ecs update-service --region ap-northeast-2 --cluster auction --service auction --force-new-deployment'
}
echo '------Deploy FINISH ------'
}
}
}
}
post {
failure {
mail (
from: "[email protected]",
to: "[email protected]",
subject: "${env.JOB_NAME} Failure - BuildNumber:${BUILD_NUMBER}",
body: "${env.JOB_NAME} Failure - BuildNumber:${BUILD_NUMBER}"
)
}
}
}