forked from tw-bc-group/tw-wallet-backend
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathJenkinsfile.groovy
75 lines (69 loc) · 2.56 KB
/
Jenkinsfile.groovy
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
def COLOR_MAP = [
'SUCCESS': 'good',
'FAILURE': 'danger',
]
pipeline {
agent any
environment {
DB_USERNAME = "${DB_USERNAME}"
DB_PASSWORD = "${DB_PASSWORD}"
DB_URL = "${DB_URL}"
NODE1_PRIVATE_KEY = "${NODE1_PRIVATE_KEY}"
TWPOINT_CONTRACT_ADDRESS = "${TWPOINT_CONTRACT_ADDRESS}"
IDENTITY_REGISTRY_CONTRACT_ADDRESS = "${IDENTITY_REGISTRY_CONTRACT_ADDRESS}"
HEALTH_VERIFICATION_CLAIM_CONTRACT_ADDRESS = "${HEALTH_VERIFICATION_CLAIM_CONTRACT_ADDRESS}"
HEALTH_VERIFICATION_CLAIM_ISSUER_ADDRESS = "${HEALTH_VERIFICATION_CLAIM_ISSUER_ADDRESS}"
HEALTH_VERIFICATION_CLAIM_ISSUER_PRIVATE_KEY = "${HEALTH_VERIFICATION_CLAIM_ISSUER_PRIVATE_KEY}"
RPC_URL = "${RPC_URL}"
DOCKER_REG = "${DOCKER_REGISTRY}"
LOG_DIR = "${LOG_DIR}"
HOST_IP = "${HOST_IP}"
IMAGE_NAME = "${DOCKER_REGISTRY}/tw-wallet"
IMAGE_TAG = "build-${BUILD_NUMBER}"
}
stages {
stage('Migration') {
steps {
sh './gradlew --no-daemon -Penv=dev flywayMigrate'
}
}
stage('Build') {
steps {
// sh 'make cache'
// sh 'make build'
// TODO: Remove this workaround
sh './gradlew --no-daemon -Penv=dev clean build -x test'
}
}
stage('Dockerize') {
steps {
sh 'docker build -t ${IMAGE_NAME}:${IMAGE_TAG} .'
}
}
stage('Push') {
steps {
sh '''
export AWS_PROFILE=tw-bc-cn
aws ecr get-login-password | docker login --username AWS --password-stdin ${DOCKER_REGISTRY}
docker push ${IMAGE_NAME}:${IMAGE_TAG}
docker rmi ${IMAGE_NAME}:${IMAGE_TAG}
'''
}
}
stage('Deploy') {
steps {
sh 'env > .env'
sh 'kubectl get namespaces tw-wallet-backend-ns || kubectl create namespace tw-wallet-backend-ns'
sh 'helm -n tw-wallet-backend-ns upgrade --install tw-wallet-backend ./helm --set image.tag=${IMAGE_TAG} --set image.repository=${IMAGE_NAME}'
}
}
}
post {
always {
echo 'Time to send slack message.'
slackSend channel: '#wallet',
color: COLOR_MAP[currentBuild.currentResult],
message: "*${currentBuild.currentResult}:* Job ${env.JOB_NAME} build ${env.BUILD_NUMBER} on (<${env.BUILD_URL}|Open>)"
}
}
}