diff --git a/tests/Jenkinsfile b/tests/Jenkinsfile index e343de789e466143ca05a1e2c42275709aaa9c2a..550a0d29ed2229acb85c0e08a3de77a62c36be0d 100644 --- a/tests/Jenkinsfile +++ b/tests/Jenkinsfile @@ -1,3 +1,32 @@ +import hudson.model.Result +import jenkins.model.CauseOfInterruption +properties([pipelineTriggers([githubPush()])]) +node { + git url: 'https://github.com/taosdata/TDengine.git' +} + + +def abortPreviousBuilds() { + def currentJobName = env.JOB_NAME + def currentBuildNumber = env.BUILD_NUMBER.toInteger() + def jobs = Jenkins.instance.getItemByFullName(currentJobName) + def builds = jobs.getBuilds() + + for (build in builds) { + if (!build.isBuilding()) { + continue; + } + + if (currentBuildNumber == build.getNumber().toInteger()) { + continue; + } + + build.doKill() //doTerm(),doKill(),doTerm() + } +} +//停止之前相同的分支。。 +abortPreviousBuilds() + def pre_test(){ catchError(buildResult: 'SUCCESS', stageResult: 'FAILURE') { sh ''' @@ -5,15 +34,17 @@ def pre_test(){ ''' } sh ''' + cd ${WKC} - git reset --hard - git checkout ${BRANCH} - git pull - git submodule update + rm -rf * cd ${WK} git reset --hard - git checkout ${BRANCH} + git checkout develop git pull + cd ${WKC} + rm -rf * + mv ${WORKSPACE}/* . + cd ${WK} export TZ=Asia/Harbin date rm -rf ${WK}/debug @@ -22,23 +53,30 @@ def pre_test(){ cmake .. > /dev/null make > /dev/null make install > /dev/null + cd ${WKC}/tests ''' return 1 } pipeline { agent none + environment{ - BRANCH = 'develop' WK = '/var/lib/jenkins/workspace/TDinternal' WKC= '/var/lib/jenkins/workspace/TDinternal/community' } - + stages { + + stage('Parallel test stage') { + //only pr triggering the build. + when { + changeRequest() + } parallel { - stage('pytest') { - agent{label '184'} - steps { + stage('python') { + agent{label 'pytest'} + steps { pre_test() sh ''' cd ${WKC}/tests @@ -47,15 +85,9 @@ pipeline { } } stage('test_b1') { - agent{label 'master'} - steps { + agent{label 'b1'} + steps { pre_test() - catchError(buildResult: 'SUCCESS', stageResult: 'FAILURE') { - sh ''' - cd ${WKC}/tests/pytest - python3 concurrent_inquiry.py -c 1 - ''' - } sh ''' cd ${WKC}/tests ./test-all.sh b1 @@ -64,12 +96,9 @@ pipeline { } stage('test_crash_gen') { - agent{label "185"} + agent{label "b2"} steps { pre_test() - sh ''' - cd ${WKC}/tests/pytest - ''' catchError(buildResult: 'SUCCESS', stageResult: 'FAILURE') { sh ''' cd ${WKC}/tests/pytest @@ -83,6 +112,7 @@ pipeline { ''' } sh ''' + date cd ${WKC}/tests ./test-all.sh b2 date @@ -91,177 +121,27 @@ pipeline { } stage('test_valgrind') { - agent{label "186"} + agent{label "b3"} steps { pre_test() + catchError(buildResult: 'SUCCESS', stageResult: 'FAILURE') { + sh ''' + cd ${WKC}/tests/pytest + ./valgrind-test.sh 2>&1 > mem-error-out.log + ./handle_val_log.sh + ''' + } sh ''' - cd ${WKC}/tests/pytest - ./valgrind-test.sh 2>&1 > mem-error-out.log - ./handle_val_log.sh - date cd ${WKC}/tests ./test-all.sh b3 date''' } } - stage('connector'){ - agent{label "release"} - steps{ - sh''' - cd ${WORKSPACE} - git checkout develop - ''' - catchError(buildResult: 'SUCCESS', stageResult: 'FAILURE') { - sh ''' - cd ${WORKSPACE}/tests/gotest - bash batchtest.sh - ''' - } - catchError(buildResult: 'SUCCESS', stageResult: 'FAILURE') { - sh ''' - cd ${WORKSPACE}/tests/examples/python/PYTHONConnectorChecker - python3 PythonChecker.py - ''' - } - catchError(buildResult: 'SUCCESS', stageResult: 'FAILURE') { - sh ''' - cd ${WORKSPACE}/tests/examples/JDBC/JDBCDemo/ - mvn clean package assembly:single >/dev/null - java -jar target/jdbcChecker-SNAPSHOT-jar-with-dependencies.jar -host 127.0.0.1 - ''' - } - catchError(buildResult: 'SUCCESS', stageResult: 'FAILURE') { - sh ''' - cd ${JENKINS_HOME}/workspace/C#NET/src/CheckC# - dotnet run - ''' - } - - } - } - stage('arm64_build'){ - agent{label 'arm64'} - steps{ - sh ''' - cd ${WK} - git fetch - git checkout develop - git pull - cd ${WKC} - git fetch - git checkout develop - git pull - git submodule update - cd ${WKC}/packaging - ./release.sh -v cluster -c aarch64 -n 2.0.0.0 -m 2.0.0.0 - - ''' - } - } - stage('arm32_build'){ - agent{label 'arm32'} - steps{ - catchError(buildResult: 'SUCCESS', stageResult: 'FAILURE') { - sh ''' - cd ${WK} - git fetch - git checkout develop - git pull - cd ${WKC} - git fetch - git checkout develop - git pull - git submodule update - cd ${WKC}/packaging - ./release.sh -v cluster -c aarch32 -n 2.0.0.0 -m 2.0.0.0 - - ''' - } - - } - } - } + } - } - post { - success { - emailext ( - subject: "SUCCESSFUL: Job '${env.JOB_NAME} [${env.BUILD_NUMBER}]'", - body: ''' - -
- - - -- 构建信息 - |
-
-
-
- |
-
- 构建信息 - |
-
-
-
- |
-