pipeline 語法實例二

pipeline 語法實例二

Node 前端 We b頁面, npm 是 JavaScript 的包管理工具。

/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*

pipeline {
    agent any
    options {
        timestamps()
        timeout(10)
    }
    stages {
        stage('Checkout') {
            steps {
            git branch: '${branch_name}', credentialsId: 'GitLabAccess', url:'${repo_name}'
            }
        }
        stage('Build') {
            steps {
                nodejs('nodejs_12.9.1'){
                    sh "npm install"
                    sh "npm run build"
                    //sh "npm run build:physics"
                }
            }
        }
        /*stage('Package') {
            steps {
                sleep 1
                sh """
                    cd /home/jenkins/workspace/jenkins-quality-front-ci
                    if [ -d "quality-front" ]; then
                       rm -rf quality-front
                    fi
                    sleep 1
                    if [ -f "quality-front.tar.gz" ]; then
                       rm -rf quality-front.tar.gz
                    fi
                    sleep 1
                    mkdir quality-front
                    sleep 2
                    cp -rf dist scripts template quality-front
                    sleep 2
                    tar -zcvf quality-front.tar.gz  quality-front
                """
                
            }
        }*/
        stage('Deploy') {
            steps {
                sh "cd /home/jenkins/workspace/jenkins-quality-front-ci && scp -r quality-front*.tar.gz [email protected]:/opt/web-front/scmdeploy"
                sh "ssh -tt [email protected] cp -rf /opt/web-front/quality-front /opt/web-front/scm-backup/"
                sh "ssh -tt [email protected] rm -rf /opt/web-front/quality-front/dist/*"
                sleep 1
                sh "cd dist && scp -r * [email protected]:/opt/web-front/scmdeploy/quality-front/dist/"
                sh "ssh -tt [email protected] cp -rf /opt/web-front/scmdeploy/quality-front/dist/* /opt/web-front/quality-front/dist/"
                sleep 1
                sh "ssh -tt [email protected] cp -rf /opt/web-front/config-jsbak/quality-front/config.js /opt/web-front/quality-front/dist/"
                //sleep 1
                //sh "ssh -tt [email protected] chmod -R 755 /opt/web-front/quality-front/dist"
            }
        }
        
        stage("SendMail") {
            steps{
                script {
                    mail to: '[email protected]',
                    cc: '[email protected]',
                    charset : 'UTF-8',
                    mimeType : 'test/plain',
                    subject: "Running Pipeline: ${currentBuild.fullDisplayName}",
                    body: "Something is wrong with : ${env.BUILD_URL}, just for test send mail via pipeline code"
                }
            }
        }
        
        /*stage('show gitstats') {
            steps {
                sh "/usr/bin/cloc . && pwd"
                //sh "/usr/bin/gitstats ${WORKSPACE}/ ${WORKSPACE}/jenkins-quality-front-ci_rp20191104"
            }
        }*/
        
        /*stage("send mail test") {
            steps{
                script {
                    mail to: '[email protected]',
                    subject: "Running Pipeline: ${currentBuild.fullDisplayName}",
                    body: "Something is wrong with : ${env.BUILD_URL}"
                }
            }
        }*/
    }
    
    /*post {
        failure {
            mail to : '[email protected]',
            subject : "Failed Pipeline: ${currentBuild.fullDisplayName}",
            body : "Something is wrong with ${emv.BUILD_URL}"
        }
    }*/
   
}

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章