贴出一个nodejs项目的jenkinsfile,与dockerfile结合,实现持续发布的功能
#!groovy
pipeline {
agent any
stages{
stage('Build') {
parallel {
stage('Lint') {
steps {
sh "npm run tslint"
}
}
stage('Compile') {
steps {
sh "npm run build"
}
}
}
}
stage('zip'){
steps{
sh """
rm -rf *.zip
zip -r -q demo.zip *
"""
}
}
stage('docker build'){
steps{
sh """
docker build -f ./Dockerfile . -t node-test:v$BUILD_NUMBER
docker login reg.qiniu.com -u lugo@test.com -p test33
docker tag node-test:v$BUILD_NUMBER reg.qiniu.com/lugo/node-test:v$BUILD_NUMBER
docker push reg.qiniu.com/lugo/node-test:v$BUILD_NUMBER
"""
}
}
stage('ansible deploy'){
steps{
sh """
ansible-playbook /etc/ansible/playbook/node_test.yml -e image_name=reg.qiniu.com/lugo/node-test:v$BUILD_NUMBER
"""
}
}
}
}
网友评论