Skip to content
Somkiat Puisungnoen edited this page Apr 20, 2021 · 2 revisions

Pipeline script

pipeline {
    agent any

    stages {
        stage('demo01') {
            steps {
                git branch: 'main', url: 'https://github.com/up1/workshop-nodejs-ci-cd.git'
                sh '''npm install
npm test'''
                build wait: false, job: 'sonarqube'
            }
        }
        stage('deploy') {
            steps {
                sh 'pm2 restart all'
            }
        }
        stage('api-test') {
            steps {
                sh '''cd postman
newman run day01.postman_collection.json -r cli,junit'''
            }
        }
    }
}

pipeline {
    agent any

    stages {
        stage('demo01') {
            steps {
                git branch: 'main', url: 'https://github.com/up1/workshop-nodejs-ci-cd.git'
                sh '''npm install
npm test'''
            }
        }
        stage('demo-parallel') {
            parallel {
                stage('sonarqube') {
                    steps { 
                        build wait: false, job: 'sonarqube' 
                    }
                }
                stage('deploy') {
                    steps {
                        sh 'pm2 restart all'
                    }
                }
            }
        }
        stage('api-test') {
            steps {
                sh '''cd postman
newman run day01.postman_collection.json -r cli,junit'''
            }
        }
    }
}

Clone this wiki locally