Files
airport-chengdu-web/jenkins/Jenkinsfile
T

37 lines
1.5 KiB
Groovy
Raw Normal View History

2018-11-06 14:09:43 +08:00
node {
checkout scm
2018-11-06 15:25:21 +08:00
docker.image('teracy/angular-cli').inside() {
2018-11-06 14:09:43 +08:00
stage('build'){
2018-11-06 15:25:21 +08:00
sh 'npm config set registry http://registry.npm.taobao.org/'
2018-11-06 14:09:43 +08:00
sh 'npm install'
sh 'ng build'
}
}
2018-11-06 15:25:21 +08:00
def imagesName = '130.120.3.193/com.gzzn.omms/admin-web:0.0.1-SNAPSHOT'
2018-11-06 14:09:43 +08:00
stage('Image Build And Push'){
2018-11-06 15:25:21 +08:00
docker.withRegistry('http://130.120.3.193', 'privateDockerId') {
2018-11-06 14:09:43 +08:00
docker.build(imagesName).push()
}
}
stage('deploy'){
2018-11-06 15:09:45 +08:00
def remote = [:]
2018-11-06 15:25:21 +08:00
remote.name = "airport-dev"
remote.host = "130.120.3.231"
2018-11-06 14:09:43 +08:00
remote.allowAnyHosts = true
2018-11-06 15:25:21 +08:00
withCredentials([sshUserPrivateKey(credentialsId: 'e41b57a4-436a-4617-817c-9e3f25a8a47f', keyFileVariable: 'kfIdentity', passphraseVariable: 'pVariable', usernameVariable: 'userName')]) {
2018-11-06 14:09:43 +08:00
remote.user = userName
remote.identityFile = kfIdentity
2018-11-06 15:25:21 +08:00
sshCommand remote: remote, command: "docker stop adminweb",sudo: true ,failOnError: false
sshCommand remote: remote, command: "docker rm adminweb",sudo: true ,failOnError: false
sshCommand remote: remote, command: "docker rmi 130.120.3.193/com.gzzn.omms/admin-web:0.0.1-SNAPSHOT",sudo: true ,failOnError: false
sshCommand remote: remote, command: "docker run -d -p 96:80 --name adminweb 130.120.3.193/com.gzzn.omms/admin-web:0.0.1-SNAPSHOT",sudo: true
2018-11-06 14:09:43 +08:00
}
}
}