ansible简单部署前端

pipeline{
agent any
parameters {
choice(name: 'server_name', choices: ['xx','xx'], description: 'server_name')
text(name: 'tag', defaultValue: '', description: '版本tag号')
}
environment {
SERVER_NAME = "${params.server_name}"
DEPLOY_SOURCE= "/data/share/svn/${params.tag}"
DEPLOY_DEST= "/opt/static/xxx"
DEPLOY_FILE="xx.tar"
}
stages{
stage('backup'){
steps{
sh "ansible $SERVER_NAME -m shell -a \"mkdir -p /opt/backup/`date +%F` && cp -r $DEPLOY_DEST /opt/backup/`date +%F`\""
}
}
stage('push'){
steps{
sh "ansible $SERVER_NAME -m copy -a \"src=$DEPLOY_SOURCE/$DEPLOY_FILE dest=$DEPLOY_DEST backup=yes\" "
}
}
stage('deploy'){
steps{
sh "ansible $SERVER_NAME -m shell -a \" tar -xvf $DEPLOY_DEST/$DEPLOY_FILE -C $DEPLOY_DEST \" "
}
}

}
}

posted @ 2019-06-12 09:45  xiao_pai_pai  阅读(380)  评论(0编辑  收藏  举报