Design Pipeline Frontend - Mrsmithz/Project-SW-Dev-and-Env GitHub Wiki

Pull Code

stage('Pull code from branch main') {
    steps {
        git branch: 'main', url: 'https://github.com/Mrsmithz/Project-SW-Dev-and-Env.git'
    }
}

Stage 1 Pull Code มาจาก Branch main

Download dependency

stage('Download dependency') {
    steps {
        dir('frontend') {
            sh 'yarn install'
        }
    }
}

Stage 2 download dependency ต่าง

Run Unit Test

stage('Run unit test') {
    steps {
        dir('frontend') {
            sh 'yarn unit-test'
        }
    }
}

Stage 3 ทำการ run unit test

Create unit test reports

stage('Create unit test report') {
    steps {
        dir('frontend') {
            script {
                if (!fileExists('reports')) {
                    mkdir reports
                }
            }
            sh 'yarn run unit-test 2> reports/unit.txt'
            publishHTML([allowMissing: false, alwaysLinkToLastBuild: false, keepAll: true, reportDir: 'reports', reportFiles: 'unit.txt', reportName: 'Unit Test Report', reportTitles: 'Unit Test Report'])
        }
    }
}

Stage 4 สร้าง unit test report

Run Component Test

stage('Run component test') {
    steps {
        dir('frontend') {
            sh 'yarn component-test'
        }
    }
}

Stage 5 ทำการ run component test

Create component test report

stage('Create component test report') {
    steps {
        dir('frontend') {
            sh 'yarn run component-test 2> reports/component.txt'
            publishHTML([allowMissing: false, alwaysLinkToLastBuild: false, keepAll: true, reportDir: 'reports', reportFiles: 'component.txt', reportName: 'Component Test Report', reportTitles: 'Component Test Report'])
        }
    }
}

Stage 6 สร้าง component test report

Run E2E test

stage('Run E2E test') {
    steps {
        dir('frontend') {
            sh 'yarn run e2e-test'
        }
    }
}

Stage 7 ทำการ run E2E test

Create E2E Test report

stage('Create E2E test report') {
    steps {
        dir('frontend') {
            sh 'yarn run e2e-test 2> reports/e2e.txt'
            publishHTML([allowMissing: false, alwaysLinkToLastBuild: false, keepAll: true, reportDir: 'reports', reportFiles: 'e2e.txt', reportName: 'E2E Test Report', reportTitles: 'E2E Test Report'])
        }
    }
}

Stage 8 ทำการสร้าง E2E test report

Build

stage('Build') {
    steps {
        dir('frontend') {
            sh 'yarn build'
        }
    }
}

Stage 9 ทำการ build