node('slave-191') { stage('从SVN拉取代码') { checkout([$class: 'SubversionSCM', additionalCredentials: [], excludedCommitMessages: '', excludedRegions: '', excludedRevprop: '', excludedUsers: '', filterChangelog: false, ignoreDirPropChanges: false, includedRegions: '', locations: [[cancelProcessOnExternalsFail: true, credentialsId: '用户名和密码ID', depthOption: 'infinity', ignoreExternalsOption: true, local: '.', remote: 'svn项目链接']], quietOperation: true, workspaceUpdater: [$class: 'UpdateUpdater']]) } stage("Install") { sh '''export Node_Home=/usr/local/node-v12.13.1 export PATH="$PATH:$Node_Home/bin" $Node_Home/bin/cnpm install''' } stage('NPM打包') { sh '''export Node_Home=/usr/local/node-v12.13.1 export PATH="$PATH:$Node_Home/bin" $Node_Home/bin/npm run build''' } stage("更改API接口地址") { sh '''sed -i 's/ip1/ip2/g' ${WORKSPACE}/dist/static/config.js ''' } stage("打包dist并归档") { sh '''tar -zcvf dist.tar.gz dist/ ''' archiveArtifacts artifacts: '*.tar.gz', fingerprint: true } stage('部署包') { sh ''' cp -r ${WORKSPACE}/dist/ /usr/local/nginx/html/ ''' } stage('测试服务启动') { sh '''running_num=`/usr/bin/systemctl status nginx| grep running | wc -l` if [ $running_num -eq 1 ];then echo "deploy success" else echo "deploy failed" exit 1 fi ''' } }
4.构建结果
免责声明:本站发布的内容(图片、视频和文字)以原创、转载和分享为主,文章观点不代表本网站立场,如果涉及侵权请联系站长邮箱:is@yisu.com进行举报,并提供相关证据,一经查实,将立刻删除涉嫌侵权内容。