-
Notifications
You must be signed in to change notification settings - Fork 8
/
Jenkinsfile
41 lines (41 loc) · 1.1 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
pipeline {
environment {
registry = 'wms2537/'
registryCredential = 'DOCKERHUB'
SERVER_IP = credentials('ALICLOUD_ECS_HK_IP')
MONGODB_WMTECH = credentials('MONGODB_WMTECH')
}
agent any
stages {
stage('Build Images') {
steps {
script {
dockerImage = docker.build(registry + 'nodejs-jwt-auth', './')
}
}
}
stage('Push Images') {
steps {
script {
docker.withRegistry('', registryCredential ) {
dockerImage.push("${env.BUILD_NUMBER}")
dockerImage.push('latest')
}
}
}
}
stage('Remove Unused Docker Image') {
steps {
sh "docker rmi ${registry}nodejs-jwt-auth"
}
}
stage('Deploy Images') {
steps {
sshagent(credentials:['ALICLOUD_HONG_KONG_SERVER_KEY']) {
sh ('scp -o StrictHostKeyChecking=no -r ./deploy root@$SERVER_IP:/root/nodejs-jwt-auth')
sh ('ssh -o StrictHostKeyChecking=no root@$SERVER_IP \"export BUILD_NUMBER=$BUILD_NUMBER && cd /root/nodejs-jwt-auth && bash ./deploy.sh\"')
}
}
}
}
}