* Fix unittest stage and use ztf concurrency.

This commit is contained in:
liyang
2023-05-12 13:03:49 +08:00
parent db3dc9fcb1
commit 8bc5aeaa42
Vendored
+50 -94
View File
@@ -27,7 +27,7 @@ pipeline {
}
}
stage('Sonar Scanner') {
stage('build quality') {
parallel {
stage('SonarQube') {
steps {
@@ -56,112 +56,68 @@ pipeline {
}
}
stage('Build Image') {
steps {
container('docker') {
sh 'docker build --pull . -f Dockerfile.test --build-arg VERSION=${ZENTAO_VERSION} --build-arg MIRROR=true --build-arg MYSQL_HOST=${MYSQL_SERVER_HOST} --build-arg MYSQL_PASSWORD=${MYSQL_ROOT_PASSWORD} -t ${MIDDLE_IMAGE_REPO}:${MIDDLE_IMAGE_TAG}'
sh 'docker push ${MIDDLE_IMAGE_REPO}:${MIDDLE_IMAGE_TAG}'
}
}
post {
success {
echo 'build image success'
}
failure {
container('xuanimbot') {
sh 'git config --global --add safe.directory $(pwd)'
sh '/usr/local/bin/xuanimbot --users "$(git show -s --format=%ae)" --title "build image" --url "${RUN_DISPLAY_URL}" --content "Build unit test image failure" --debug --custom'
}
}
}
}
}
}
stage('Unit Test') {
stages {
stage('Init') {
agent {
kubernetes {
inheritFrom 'xuanim'
containerTemplate {
name 'zentao'
image "${MIDDLE_IMAGE_REPO}:${MIDDLE_IMAGE_TAG}"
command 'sleep'
args '99d'
}
}
}
options { skipDefaultCheckout() }
stage('Unit Test') {
stages {
stage('Build Image') {
steps {
container('zentao') {
sh 'initdb.php ; /apps/zentao/test/ztest init'
}
container('docker') {
sh 'docker build --pull . -f Dockerfile.test --build-arg VERSION=${ZENTAO_VERSION} --build-arg MIRROR=true --build-arg MYSQL_HOST=${MYSQL_SERVER_HOST} --build-arg MYSQL_PASSWORD=${MYSQL_ROOT_PASSWORD} -t ${MIDDLE_IMAGE_REPO}:${MIDDLE_IMAGE_TAG}'
sh 'docker push ${MIDDLE_IMAGE_REPO}:${MIDDLE_IMAGE_TAG}'
}
}
post {
success {
sh 'echo "stage unit init success"'
echo 'build image success'
}
failure {
container('xuanimbot') {
sh 'git config --global --add safe.directory $(pwd)'
sh '/usr/local/bin/xuanimbot --users "$(git show -s --format=%ae)" --title "unittest init" --url "${RUN_DISPLAY_URL}" --content "Unit test database initialization failed" --debug --custom'
}
}
}
}
stage('Run') {
matrix {
agent {
kubernetes {
inheritFrom 'xuanim'
containerTemplate {
name 'zentao'
image "${MIDDLE_IMAGE_REPO}:${MIDDLE_IMAGE_TAG}"
command 'sleep'
args '99d'
}
}
}
options { skipDefaultCheckout() }
axes {
axis {
name 'SEQUENCE'
values 'P1', 'P2', 'P3', 'P4', 'P5', 'P6', 'P7'
}
}
stages {
stage('Run') {
steps {
container('zentao') {
sh 'initdb.php config'
sh '/apps/zentao/test/ztest extract ; /apps/zentao/test/ztest ${SEQUENCE} | tee /apps/zentao/test/${SEQUENCE}.log'
sh 'pipeline-unittest.sh /apps/zentao/test/${SEQUENCE}.log'
container('xuanimbot') {
sh 'git config --global --add safe.directory $(pwd)'
sh '/usr/local/bin/xuanimbot --users "$(git show -s --format=%ae)" --title "build image" --url "${RUN_DISPLAY_URL}" --content "Build unit test image failure" --debug --custom'
}
}
}
}
stage('Run') {
agent {
kubernetes {
inheritFrom 'xuanim'
containerTemplate {
name 'zentao'
image "${MIDDLE_IMAGE_REPO}:${MIDDLE_IMAGE_TAG}"
args 'sleep 99d'
}
}
}
options { skipDefaultCheckout() }
steps {
container('zentao') {
sh 'apachectl start ; initdb.php ; /apps/zentao/test/ztest batchInit ; /apps/zentao/test/ztest concurrency | tee /apps/zentao/test/${MIDDLE_IMAGE_TAG}.log ; parsehtml.php '
publishHTML (target : [allowMissing: false,alwaysLinkToLastBuild: false,keepAll: true,reportDir: 'coverage',reportFiles: 'index.html',reportName: 'UT Coverage Report',reportTitles: 'UT Coverage Report'])
sh 'pipeline-unittest.sh /apps/zentao/test/${MIDDLE_IMAGE_TAG}.log'
}
}
post {
success {
container('xuanimbot') {
sh 'git config --global --add safe.directory /home/jenkins/agent/workspace/pangu_pangu_xuanimbot_master'
sh '/usr/local/bin/xuanimbot --users "$(git show -s --format=%ae)" --title "unittest" --url "${RUN_DISPLAY_URL}" --content "Unit test passed" --debug --custom'
}
}
failure {
container('xuanimbot') {
sh 'git config --global --add safe.directory $(pwd)'
sh '/usr/local/bin/xuanimbot --users "$(git show -s --format=%ae)" --title "unittest" --url "${RUN_DISPLAY_URL}" --content "Unit test failed" --debug --custom'
}
}
}
post {
success {
container('xuanimbot') {
sh 'git config --global --add safe.directory /home/jenkins/agent/workspace/pangu_pangu_xuanimbot_master'
sh '/usr/local/bin/xuanimbot --users "$(git show -s --format=%ae)" --title "unittest" --url "${RUN_DISPLAY_URL}" --content "Unit test passed" --debug --custom'
}
}
failure {
container('xuanimbot') {
sh 'git config --global --add safe.directory $(pwd)'
sh '/usr/local/bin/xuanimbot --users "$(git show -s --format=%ae)" --title "unittest" --url "${RUN_DISPLAY_URL}" --content "Unit test failed" --debug --custom'
}
}
}
}//End unittest
}//End unittest
}
}
} // End Root Stages
}// End Root Stages
} // End pipeline