From e4b462f27b7704067c9752889cf1d025503e50e7 Mon Sep 17 00:00:00 2001 From: tangfangzhi Date: Wed, 22 Jun 2022 09:35:54 +0800 Subject: [PATCH] ci: split ci environment into two --- Jenkinsfile2 | 141 ++++++++++++++++++--------------------------------- 1 file changed, 49 insertions(+), 92 deletions(-) diff --git a/Jenkinsfile2 b/Jenkinsfile2 index fceaa6554f..79954fb969 100644 --- a/Jenkinsfile2 +++ b/Jenkinsfile2 @@ -7,7 +7,8 @@ def sync_source() { sh ''' hostname date - ''' + env + ''' sh ''' cd ${WKC} [ -f src/connector/grafanaplugin/README.md ] && rm -f src/connector/grafanaplugin/README.md > /dev/null || echo "failed to remove grafanaplugin README.md" @@ -36,6 +37,12 @@ def sync_source() { git clean -fxd git checkout 2.4 ''' + } else if (env.CHANGE_TARGET == '2.6') { + sh ''' + cd ${WKC} + git clean -fxd + git checkout 2.6 + ''' } else { sh ''' cd ${WKC} @@ -51,6 +58,7 @@ def sync_source() { [ -f src/connector/grafanaplugin/README.md ] && rm -f src/connector/grafanaplugin/README.md > /dev/null || echo "failed to remove grafanaplugin README.md" git pull >/dev/null git clean -dfx + git log -5 ''' script { if (env.CHANGE_TARGET == 'master') { @@ -68,6 +76,11 @@ def sync_source() { cd ${WK} git checkout 2.4 ''' + } else if (env.CHANGE_TARGET == '2.6') { + sh ''' + cd ${WK} + git checkout 2.6 + ''' } else { sh ''' cd ${WK} @@ -79,6 +92,7 @@ def sync_source() { cd ${WK} git pull >/dev/null git clean -dfx + git log -5 ''' script { if (env.CHANGE_URL =~ /\/TDengine\//) { @@ -87,16 +101,13 @@ def sync_source() { cd ${WKC} git fetch origin +refs/pull/${CHANGE_ID}/merge git checkout -qf FETCH_HEAD - - if [ ! -d src/connector/python/.github ]; then - rm -rf src/connector/python/* || : - rm -rf src/connector/python/.* || : - git clone --depth 1 https://github.com/taosdata/taos-connector-python src/connector/python || echo "failed to clone python connector" - else - cd src/connector/python || echo "src/connector/python not exist" - git pull || : - cd ${WKC} - fi + git log -5 + ''' + sh ''' + cd ${WKC} + rm -rf src/connector/python + mkdir -p src/connector/python + git clone --depth 1 https://github.com/taosdata/taos-connector-python src/connector/python || echo "failed to clone python connector" ''' } else if (env.CHANGE_URL =~ /\/TDinternal\//) { sh ''' @@ -104,16 +115,13 @@ def sync_source() { cd ${WK} git fetch origin +refs/pull/${CHANGE_ID}/merge git checkout -qf FETCH_HEAD - - if [ ! -d community/src/connector/python/.github ]; then - rm -rf community/src/connector/python/* || : - rm -rf community/src/connector/python/.* || : - git clone --depth 1 https://github.com/taosdata/taos-connector-python community/src/connector/python || echo "failed to clone python connector" - else - cd community/src/connector/python || echo "community/src/connector/python not exist" - git pull || : - cd ${WK} - fi + git log -5 + ''' + sh ''' + cd ${WKC} + rm -rf src/connector/python + mkdir -p src/connector/python + git clone --depth 1 https://github.com/taosdata/taos-connector-python src/connector/python || echo "failed to clone python connector" ''' } else { sh ''' @@ -136,6 +144,7 @@ def pre_test() { go env -w GO111MODULE=on cmake .. -DBUILD_HTTP=false -DBUILD_TOOLS=true > /dev/null make -j8 >/dev/null + make install ''' return 1 } @@ -153,7 +162,7 @@ def pre_test_mac() { return 1 } pipeline { - agent {label " dispatcher "} + agent none options { skipDefaultCheckout() } environment{ WK = '/var/data/jenkins/workspace/TDinternal' @@ -161,69 +170,6 @@ pipeline { LOGDIR = '/var/data/jenkins/workspace/log' } stages { - stage ('pre_build') { - steps { - sh ''' - date - pwd - env - hostname - ''' - } - } - stage ('Parallel build stage') { - //only build pr - options { skipDefaultCheckout() } - when { - allOf { - changeRequest() - not { expression { env.CHANGE_BRANCH =~ /docs\// }} - } - } - parallel { - stage ('dispatcher sync source') { - steps { - timeout(time: 20, unit: 'MINUTES') { - sync_source() - script { - sh ''' - echo "dispatcher ready" - date - ''' - } - } - } - } - stage ('build worker01') { - agent {label " worker01 "} - steps { - timeout(time: 20, unit: 'MINUTES') { - pre_test() - script { - sh ''' - echo "worker01 build done" - date - ''' - } - } - } - } - stage ('build worker02') { - agent {label " worker02 "} - steps { - timeout(time: 20, unit: 'MINUTES') { - pre_test() - script { - sh ''' - echo "worker02 build done" - date - ''' - } - } - } - } - } - } stage('run test') { options { skipDefaultCheckout() } when { @@ -233,28 +179,28 @@ pipeline { } } parallel { - stage ('build worker07_arm64') { - agent {label " worker07_arm64 "} + stage ('build arm64') { + agent {label " worker07_arm64 || worker09_arm64 "} steps { timeout(time: 20, unit: 'MINUTES') { pre_test() script { sh ''' - echo "worker07_arm64 build done" + echo "arm64 build done" date ''' } } } } - stage ('build Mac_catalina ') { + stage ('build Mac') { agent {label " Mac_catalina "} steps { timeout(time: 20, unit: 'MINUTES') { pre_test_mac() script { sh ''' - echo "Mac_catalina build done" + echo "Mac build done" date ''' } @@ -262,17 +208,28 @@ pipeline { } } stage('run cases') { + agent {label " worker01 || worker02 "} steps { sh ''' date + pwd hostname ''' + timeout(time: 15, unit: 'MINUTES') { + pre_test() + script { + sh ''' + echo "Linux build done" + date + ''' + } + } catchError(buildResult: 'FAILURE', stageResult: 'FAILURE') { - timeout(time: 20, unit: 'MINUTES') { + timeout(time: 25, unit: 'MINUTES') { sh ''' date cd ${WKC}/tests/parallel_test - time ./run.sh -m m.json -t cases.task -l ${LOGDIR} -b ${BRANCH_NAME} + time ./run.sh -m /home/m.json -t cases.task -l ${LOGDIR} -b ${BRANCH_NAME} date hostname ''' -- GitLab