Jenkins VUE front-end automation of packaged and released

1. Demand

VUE enables the development front-end project automation packaged and released, do the appropriate update their own front end, saving time communication

2. implementation

Jenkins slave using the pipeline call cnpm order to build VUE project

3.pipeline

node('slave-191') {
    Stage ( 'pulled from SVN code') {
       checkout([$class: 'SubversionSCM', additionalCredentials: [], excludedCommitMessages: '', excludedRegions: '', excludedRevprop: '', 
       excludedUsers: '', filterChangelog: false, ignoreDirPropChanges: false, includedRegions: '', locations: [[cancelProcessOnExternalsFail: true, 
       credentialsId: 'username and password 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 packaged') {
        sh '''export Node_Home=/usr/local/node-v12.13.1
        export PATH="$PATH:$Node_Home/bin"
        $Node_Home/bin/npm run build'''
    }
    stage ( "API interface address change") {
        sh '''sed -i 's/ip1/ip2/g' ${WORKSPACE}/dist/static/config.js
        '''
    }
    Stage ( "package archive and dist") {
         sh '' 'tar -zcvf dist.tar.gz dist /
         '''
         archiveArtifacts artifacts: '*.tar.gz', fingerprint: true
    }
    Stage ( 'deployment package') {
        sh '''
        cp -r ${WORKSPACE}/dist/ /usr/local/nginx/html/
        '''
    }
    Stage ( 'test service startup') {
        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
        be
        '''
    }
}

4. Results Construction

image.png

Guess you like

Origin blog.51cto.com/12217124/2477108