Design Pipeline Backend - 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('backend') {
sh 'npm install'
}
}
}
Stage 2 ทำการ download dependency
Run Unit Test
stage('Run unit test') {
steps {
dir('backend') {
sh 'npm run test'
}
}
}
Stage 3 ทำการ run unit test
Create unit test report
stage('Create unit test report') {
steps {
dir('backend') {
script {
if (!fileExists('reports')) {
sh 'mkdir reports'
}
}
sh 'npm run 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