-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathbackend-dev.jenkinsfile
More file actions
57 lines (54 loc) · 1.84 KB
/
backend-dev.jenkinsfile
File metadata and controls
57 lines (54 loc) · 1.84 KB
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
pipeline {
agent any
options {
timeout(time: 1, unit: 'HOURS') // set timeout 1 hour
}
environment {
TIME_ZONE = 'Asia/Seoul'
PROFILE = 'local'
AWS_CREDENTIAL_ID = "ccb582b8-415d-45b1-b076-65bc52f1d839"
REGION = 'ap-northeast-2'
JAR_FILE = "build/libs/*.jar"
IMAGE_NAME = "tasker-image"
REGISTRY_URL = "415154241470.dkr.ecr.ap-northeast-2.amazonaws.com"
ECR_REPO = "tasker-ecr-repo"
}
stages {
stage('Build') {
steps {
sh 'chmod +x ./gradlew'
sh './gradlew build'
}
}
stage('Build Docker Image') {
steps {
script {
try {
withEnv(['JASYPT_PASSWORD=${env.JASYPT_PASSWORD}']) {
docker.build("${ECR_REPO}:${BUILD_NUMBER}")
}
} catch (err) {
currentBuild.result = 'FAILURE'
error "Error occurred while building docker image: ${err}"
}
}
}
}
stage('Push Docker Image') {
steps {
script {
try {
docker.withRegistry("https://${REGISTRY_URL}", "ecr:${REGION}:${AWS_CREDENTIAL_ID}") {
def image = "${ECR_REPO}:${BUILD_NUMBER}"
dockerImage = docker.image(image)
dockerImage.push()
}
} catch (err) {
currentBuild.result = 'FAILURE'
error "Error occurred while pushing docker image: ${err}"
}
}
}
}
}
}