From 3dc7f0e6d33093627f9712a05d5858ef2ce721a1 Mon Sep 17 00:00:00 2001 From: glorv Date: Fri, 3 Apr 2020 21:28:39 +0800 Subject: [PATCH 1/2] fix ci pipeline if not triggered by pr --- scripts/groovy/binlog_ghpr_build.groovy | 9 +++++++-- scripts/groovy/binlog_ghpr_check.groovy | 8 ++++++-- scripts/groovy/binlog_ghpr_integration.groovy | 9 +++++++-- scripts/groovy/binlog_ghpr_unit_test.groovy | 10 ++++++++-- 4 files changed, 28 insertions(+), 8 deletions(-) diff --git a/scripts/groovy/binlog_ghpr_build.groovy b/scripts/groovy/binlog_ghpr_build.groovy index 89ebb0a45..2679c82b5 100644 --- a/scripts/groovy/binlog_ghpr_build.groovy +++ b/scripts/groovy/binlog_ghpr_build.groovy @@ -1,3 +1,8 @@ +def rsfSpec = "+refs/pull/${ghprbPullId}/*:refs/remotes/origin/pr/${ghprbPullId}/*" +if (ghprbPullId == null || ghprbPullId == "") { + refSpec = "+refs/heads/*:refs/remotes/origin/*" +} + catchError { node("build_go1130_binlog") { deleteDir() @@ -8,7 +13,7 @@ catchError { deleteDir() } try { - checkout changelog: false, poll: false, scm: [$class: 'GitSCM', branches: [[name: 'master']], doGenerateSubmoduleConfigurations: false, extensions: [[$class: 'PruneStaleBranch'], [$class: 'CleanBeforeCheckout']], submoduleCfg: [], userRemoteConfigs: [[credentialsId: 'github-sre-bot-ssh', refspec: '+refs/pull/*:refs/remotes/origin/pr/*', url: 'git@github.com:pingcap/tidb-binlog.git']]] + checkout changelog: false, poll: false, scm: [$class: 'GitSCM', branches: [[name: 'master']], doGenerateSubmoduleConfigurations: false, extensions: [[$class: 'PruneStaleBranch'], [$class: 'CleanBeforeCheckout']], submoduleCfg: [], userRemoteConfigs: [[credentialsId: 'github-sre-bot-ssh', refspec: rsfSpec, url: 'git@github.com:pingcap/tidb-binlog.git']]] } catch (error) { retry(2) { echo "checkout failed, retry.." @@ -16,7 +21,7 @@ catchError { if (sh(returnStatus: true, script: '[ -d .git ] && [ -f Makefile ] && git rev-parse --git-dir > /dev/null 2>&1') != 0) { deleteDir() } - checkout changelog: false, poll: false, scm: [$class: 'GitSCM', branches: [[name: 'master']], doGenerateSubmoduleConfigurations: false, extensions: [[$class: 'PruneStaleBranch'], [$class: 'CleanBeforeCheckout']], submoduleCfg: [], userRemoteConfigs: [[credentialsId: 'github-sre-bot-ssh', refspec: '+refs/pull/*:refs/remotes/origin/pr/*', url: 'git@github.com:pingcap/tidb-binlog.git']]] + checkout changelog: false, poll: false, scm: [$class: 'GitSCM', branches: [[name: 'master']], doGenerateSubmoduleConfigurations: false, extensions: [[$class: 'PruneStaleBranch'], [$class: 'CleanBeforeCheckout']], submoduleCfg: [], userRemoteConfigs: [[credentialsId: 'github-sre-bot-ssh', refspec: refSpec, url: 'git@github.com:pingcap/tidb-binlog.git']]] } } } diff --git a/scripts/groovy/binlog_ghpr_check.groovy b/scripts/groovy/binlog_ghpr_check.groovy index f04ef730d..6de402b18 100644 --- a/scripts/groovy/binlog_ghpr_check.groovy +++ b/scripts/groovy/binlog_ghpr_check.groovy @@ -1,3 +1,7 @@ +def rsfSpec = "+refs/pull/${ghprbPullId}/*:refs/remotes/origin/pr/${ghprbPullId}/*" +if (ghprbPullId == null || ghprbPullId == "") { + refSpec = "+refs/heads/*:refs/remotes/origin/*" +} catchError { node("build_go1130_binlog") { @@ -9,7 +13,7 @@ catchError { deleteDir() } try { - checkout changelog: false, poll: false, scm: [$class: 'GitSCM', branches: [[name: 'master']], doGenerateSubmoduleConfigurations: false, extensions: [[$class: 'PruneStaleBranch'], [$class: 'CleanBeforeCheckout']], submoduleCfg: [], userRemoteConfigs: [[credentialsId: 'github-sre-bot-ssh', refspec: '+refs/pull/*:refs/remotes/origin/pr/*', url: 'git@github.com:pingcap/tidb-binlog.git']]] + checkout changelog: false, poll: false, scm: [$class: 'GitSCM', branches: [[name: 'master']], doGenerateSubmoduleConfigurations: false, extensions: [[$class: 'PruneStaleBranch'], [$class: 'CleanBeforeCheckout']], submoduleCfg: [], userRemoteConfigs: [[credentialsId: 'github-sre-bot-ssh', refspec: refSpec, url: 'git@github.com:pingcap/tidb-binlog.git']]] } catch (error) { retry(2) { echo "checkout failed, retry.." @@ -17,7 +21,7 @@ catchError { if (sh(returnStatus: true, script: '[ -d .git ] && [ -f Makefile ] && git rev-parse --git-dir > /dev/null 2>&1') != 0) { deleteDir() } - checkout changelog: false, poll: false, scm: [$class: 'GitSCM', branches: [[name: 'master']], doGenerateSubmoduleConfigurations: false, extensions: [[$class: 'PruneStaleBranch'], [$class: 'CleanBeforeCheckout']], submoduleCfg: [], userRemoteConfigs: [[credentialsId: 'github-sre-bot-ssh', refspec: '+refs/pull/*:refs/remotes/origin/pr/*', url: 'git@github.com:pingcap/tidb-binlog.git']]] + checkout changelog: false, poll: false, scm: [$class: 'GitSCM', branches: [[name: 'master']], doGenerateSubmoduleConfigurations: false, extensions: [[$class: 'PruneStaleBranch'], [$class: 'CleanBeforeCheckout']], submoduleCfg: [], userRemoteConfigs: [[credentialsId: 'github-sre-bot-ssh', refspec: refSpec, url: 'git@github.com:pingcap/tidb-binlog.git']]] } } } diff --git a/scripts/groovy/binlog_ghpr_integration.groovy b/scripts/groovy/binlog_ghpr_integration.groovy index ffd9b69b3..a39f92e9d 100644 --- a/scripts/groovy/binlog_ghpr_integration.groovy +++ b/scripts/groovy/binlog_ghpr_integration.groovy @@ -24,6 +24,11 @@ if (m3) { m3 = null println "TIDB_BRANCH=${TIDB_BRANCH}" +def rsfSpec = "+refs/pull/${ghprbPullId}/*:refs/remotes/origin/pr/${ghprbPullId}/*" +if (ghprbPullId == null || ghprbPullId == "") { + refSpec = "+refs/heads/*:refs/remotes/origin/*" +} + try { def buildSlave = "${GO_BUILD_SLAVE}" stage('Prepare') { @@ -37,7 +42,7 @@ try { deleteDir() } try { - checkout changelog: false, poll: false, scm: [$class: 'GitSCM', branches: [[name: 'master']], doGenerateSubmoduleConfigurations: false, extensions: [[$class: 'PruneStaleBranch'], [$class: 'CleanBeforeCheckout']], submoduleCfg: [], userRemoteConfigs: [[credentialsId: 'github-sre-bot-ssh', refspec: '+refs/pull/*:refs/remotes/origin/pr/*', url: 'git@github.com:pingcap/tidb-binlog.git']]] + checkout changelog: false, poll: false, scm: [$class: 'GitSCM', branches: [[name: 'master']], doGenerateSubmoduleConfigurations: false, extensions: [[$class: 'PruneStaleBranch'], [$class: 'CleanBeforeCheckout']], submoduleCfg: [], userRemoteConfigs: [[credentialsId: 'github-sre-bot-ssh', refspec: rsfSpec, url: 'git@github.com:pingcap/tidb-binlog.git']]] } catch (error) { retry(2) { echo "checkout failed, retry.." @@ -45,7 +50,7 @@ try { if (sh(returnStatus: true, script: '[ -d .git ] && [ -f Makefile ] && git rev-parse --git-dir > /dev/null 2>&1') != 0) { deleteDir() } - checkout changelog: false, poll: false, scm: [$class: 'GitSCM', branches: [[name: 'master']], doGenerateSubmoduleConfigurations: false, extensions: [[$class: 'PruneStaleBranch'], [$class: 'CleanBeforeCheckout']], submoduleCfg: [], userRemoteConfigs: [[credentialsId: 'github-sre-bot-ssh', refspec: '+refs/pull/*:refs/remotes/origin/pr/*', url: 'git@github.com:pingcap/tidb-binlog.git']]] + checkout changelog: false, poll: false, scm: [$class: 'GitSCM', branches: [[name: 'master']], doGenerateSubmoduleConfigurations: false, extensions: [[$class: 'PruneStaleBranch'], [$class: 'CleanBeforeCheckout']], submoduleCfg: [], userRemoteConfigs: [[credentialsId: 'github-sre-bot-ssh', refspec: rsfSpec, url: 'git@github.com:pingcap/tidb-binlog.git']]] } } } diff --git a/scripts/groovy/binlog_ghpr_unit_test.groovy b/scripts/groovy/binlog_ghpr_unit_test.groovy index 27b97e7bb..72479e4a0 100644 --- a/scripts/groovy/binlog_ghpr_unit_test.groovy +++ b/scripts/groovy/binlog_ghpr_unit_test.groovy @@ -1,4 +1,10 @@ def BUILD_NUMBER = "${env.BUILD_NUMBER}" + +def rsfSpec = "+refs/pull/${ghprbPullId}/*:refs/remotes/origin/pr/${ghprbPullId}/*" +if (ghprbPullId == null || ghprbPullId == "") { + refSpec = "+refs/heads/*:refs/remotes/origin/*" +} + catchError { stage("unit test") { @@ -10,7 +16,7 @@ catchError { deleteDir() } try { - checkout changelog: false, poll: false, scm: [$class: 'GitSCM', branches: [[name: 'master']], doGenerateSubmoduleConfigurations: false, extensions: [[$class: 'PruneStaleBranch'], [$class: 'CleanBeforeCheckout']], submoduleCfg: [], userRemoteConfigs: [[credentialsId: 'github-sre-bot-ssh', refspec: '+refs/pull/*:refs/remotes/origin/pr/*', url: 'git@github.com:pingcap/tidb-binlog.git']]] + checkout changelog: false, poll: false, scm: [$class: 'GitSCM', branches: [[name: 'master']], doGenerateSubmoduleConfigurations: false, extensions: [[$class: 'PruneStaleBranch'], [$class: 'CleanBeforeCheckout']], submoduleCfg: [], userRemoteConfigs: [[credentialsId: 'github-sre-bot-ssh', refspec: refSpec, url: 'git@github.com:pingcap/tidb-binlog.git']]] } catch (error) { retry(2) { echo "checkout failed, retry.." @@ -18,7 +24,7 @@ catchError { if (sh(returnStatus: true, script: '[ -d .git ] && [ -f Makefile ] && git rev-parse --git-dir > /dev/null 2>&1') != 0) { deleteDir() } - checkout changelog: false, poll: false, scm: [$class: 'GitSCM', branches: [[name: 'master']], doGenerateSubmoduleConfigurations: false, extensions: [[$class: 'PruneStaleBranch'], [$class: 'CleanBeforeCheckout']], submoduleCfg: [], userRemoteConfigs: [[credentialsId: 'github-sre-bot-ssh', refspec: '+refs/pull/*:refs/remotes/origin/pr/*', url: 'git@github.com:pingcap/tidb-binlog.git']]] + checkout changelog: false, poll: false, scm: [$class: 'GitSCM', branches: [[name: 'master']], doGenerateSubmoduleConfigurations: false, extensions: [[$class: 'PruneStaleBranch'], [$class: 'CleanBeforeCheckout']], submoduleCfg: [], userRemoteConfigs: [[credentialsId: 'github-sre-bot-ssh', refspec: refSpec, url: 'git@github.com:pingcap/tidb-binlog.git']]] } } } From b6d290620ee010790566d5158a46fa346a99f602 Mon Sep 17 00:00:00 2001 From: glorv Date: Fri, 3 Apr 2020 21:43:34 +0800 Subject: [PATCH 2/2] fxi type --- scripts/groovy/binlog_ghpr_build.groovy | 4 ++-- scripts/groovy/binlog_ghpr_check.groovy | 2 +- scripts/groovy/binlog_ghpr_integration.groovy | 6 +++--- scripts/groovy/binlog_ghpr_unit_test.groovy | 2 +- 4 files changed, 7 insertions(+), 7 deletions(-) diff --git a/scripts/groovy/binlog_ghpr_build.groovy b/scripts/groovy/binlog_ghpr_build.groovy index 2679c82b5..fdd722ba4 100644 --- a/scripts/groovy/binlog_ghpr_build.groovy +++ b/scripts/groovy/binlog_ghpr_build.groovy @@ -1,4 +1,4 @@ -def rsfSpec = "+refs/pull/${ghprbPullId}/*:refs/remotes/origin/pr/${ghprbPullId}/*" +def refSpec = "+refs/pull/${ghprbPullId}/*:refs/remotes/origin/pr/${ghprbPullId}/*" if (ghprbPullId == null || ghprbPullId == "") { refSpec = "+refs/heads/*:refs/remotes/origin/*" } @@ -13,7 +13,7 @@ catchError { deleteDir() } try { - checkout changelog: false, poll: false, scm: [$class: 'GitSCM', branches: [[name: 'master']], doGenerateSubmoduleConfigurations: false, extensions: [[$class: 'PruneStaleBranch'], [$class: 'CleanBeforeCheckout']], submoduleCfg: [], userRemoteConfigs: [[credentialsId: 'github-sre-bot-ssh', refspec: rsfSpec, url: 'git@github.com:pingcap/tidb-binlog.git']]] + checkout changelog: false, poll: false, scm: [$class: 'GitSCM', branches: [[name: 'master']], doGenerateSubmoduleConfigurations: false, extensions: [[$class: 'PruneStaleBranch'], [$class: 'CleanBeforeCheckout']], submoduleCfg: [], userRemoteConfigs: [[credentialsId: 'github-sre-bot-ssh', refspec: refSpec, url: 'git@github.com:pingcap/tidb-binlog.git']]] } catch (error) { retry(2) { echo "checkout failed, retry.." diff --git a/scripts/groovy/binlog_ghpr_check.groovy b/scripts/groovy/binlog_ghpr_check.groovy index 6de402b18..661178281 100644 --- a/scripts/groovy/binlog_ghpr_check.groovy +++ b/scripts/groovy/binlog_ghpr_check.groovy @@ -1,4 +1,4 @@ -def rsfSpec = "+refs/pull/${ghprbPullId}/*:refs/remotes/origin/pr/${ghprbPullId}/*" +def refSpec = "+refs/pull/${ghprbPullId}/*:refs/remotes/origin/pr/${ghprbPullId}/*" if (ghprbPullId == null || ghprbPullId == "") { refSpec = "+refs/heads/*:refs/remotes/origin/*" } diff --git a/scripts/groovy/binlog_ghpr_integration.groovy b/scripts/groovy/binlog_ghpr_integration.groovy index a39f92e9d..d05fbd871 100644 --- a/scripts/groovy/binlog_ghpr_integration.groovy +++ b/scripts/groovy/binlog_ghpr_integration.groovy @@ -24,7 +24,7 @@ if (m3) { m3 = null println "TIDB_BRANCH=${TIDB_BRANCH}" -def rsfSpec = "+refs/pull/${ghprbPullId}/*:refs/remotes/origin/pr/${ghprbPullId}/*" +def refSpec = "+refs/pull/${ghprbPullId}/*:refs/remotes/origin/pr/${ghprbPullId}/*" if (ghprbPullId == null || ghprbPullId == "") { refSpec = "+refs/heads/*:refs/remotes/origin/*" } @@ -42,7 +42,7 @@ try { deleteDir() } try { - checkout changelog: false, poll: false, scm: [$class: 'GitSCM', branches: [[name: 'master']], doGenerateSubmoduleConfigurations: false, extensions: [[$class: 'PruneStaleBranch'], [$class: 'CleanBeforeCheckout']], submoduleCfg: [], userRemoteConfigs: [[credentialsId: 'github-sre-bot-ssh', refspec: rsfSpec, url: 'git@github.com:pingcap/tidb-binlog.git']]] + checkout changelog: false, poll: false, scm: [$class: 'GitSCM', branches: [[name: 'master']], doGenerateSubmoduleConfigurations: false, extensions: [[$class: 'PruneStaleBranch'], [$class: 'CleanBeforeCheckout']], submoduleCfg: [], userRemoteConfigs: [[credentialsId: 'github-sre-bot-ssh', refspec: refSpec, url: 'git@github.com:pingcap/tidb-binlog.git']]] } catch (error) { retry(2) { echo "checkout failed, retry.." @@ -50,7 +50,7 @@ try { if (sh(returnStatus: true, script: '[ -d .git ] && [ -f Makefile ] && git rev-parse --git-dir > /dev/null 2>&1') != 0) { deleteDir() } - checkout changelog: false, poll: false, scm: [$class: 'GitSCM', branches: [[name: 'master']], doGenerateSubmoduleConfigurations: false, extensions: [[$class: 'PruneStaleBranch'], [$class: 'CleanBeforeCheckout']], submoduleCfg: [], userRemoteConfigs: [[credentialsId: 'github-sre-bot-ssh', refspec: rsfSpec, url: 'git@github.com:pingcap/tidb-binlog.git']]] + checkout changelog: false, poll: false, scm: [$class: 'GitSCM', branches: [[name: 'master']], doGenerateSubmoduleConfigurations: false, extensions: [[$class: 'PruneStaleBranch'], [$class: 'CleanBeforeCheckout']], submoduleCfg: [], userRemoteConfigs: [[credentialsId: 'github-sre-bot-ssh', refspec: refSpec, url: 'git@github.com:pingcap/tidb-binlog.git']]] } } } diff --git a/scripts/groovy/binlog_ghpr_unit_test.groovy b/scripts/groovy/binlog_ghpr_unit_test.groovy index 72479e4a0..62cada0ee 100644 --- a/scripts/groovy/binlog_ghpr_unit_test.groovy +++ b/scripts/groovy/binlog_ghpr_unit_test.groovy @@ -1,6 +1,6 @@ def BUILD_NUMBER = "${env.BUILD_NUMBER}" -def rsfSpec = "+refs/pull/${ghprbPullId}/*:refs/remotes/origin/pr/${ghprbPullId}/*" +def refSpec = "+refs/pull/${ghprbPullId}/*:refs/remotes/origin/pr/${ghprbPullId}/*" if (ghprbPullId == null || ghprbPullId == "") { refSpec = "+refs/heads/*:refs/remotes/origin/*" }