Skip to content

Commit 46e205a

Browse files
Support clone all repo by ssh protocol in testJob (#4228)
1 parent 7fc91a2 commit 46e205a

File tree

2 files changed

+20
-0
lines changed

2 files changed

+20
-0
lines changed

buildenv/jenkins/JenkinsfileBase

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -141,6 +141,15 @@ def setupEnv() {
141141
} else {
142142
sh 'printenv'
143143
}
144+
if ( params.USE_GIT_SSH ) {
145+
def gitGlobalConfig = fileExists('~/.gitconfig') ? sh(script:"git config --global -l", returnStdout:true) : ''
146+
if (!gitGlobalConfig || !gitGlobalConfig.contains('[email protected]:.insteadof')) {
147+
sh "git config --global url.'[email protected]:'.insteadOf 'https://github.com/'"
148+
}
149+
if (!gitGlobalConfig.contains('[email protected]:.insteadof')) {
150+
sh "git config --global url.'[email protected]:'.insteadOf 'https://gitlab.com/'"
151+
}
152+
}
144153
}
145154

146155
def setupParallelEnv() {
@@ -805,6 +814,15 @@ def testBuild() {
805814
sh "find /tmp -name '*core*' -print 2>/dev/null -exec rm -f {} \\; || true"
806815
}
807816
}
817+
if ( params.USE_GIT_SSH ) {
818+
def gitGlobalConfig = sh(script:"git config --global -l", returnStdout:true)
819+
if (gitGlobalConfig.contains('[email protected]:.insteadof')) {
820+
sh "git config --global --unset url.'[email protected]:'.insteadOf"
821+
}
822+
if (gitGlobalConfig.contains('[email protected]:.insteadof')) {
823+
sh "git config --global --unset url.'[email protected]:'.insteadOf"
824+
}
825+
}
808826
}
809827
}
810828
}

buildenv/jenkins/testJobTemplate

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,7 @@ if (!binding.hasVariable('USER_CREDENTIALS_ID')) USER_CREDENTIALS_ID = ""
6262
if (!binding.hasVariable('GENERATE_JOBS')) GENERATE_JOBS = false
6363
if (!binding.hasVariable('CLOUD_PROVIDER')) CLOUD_PROVIDER = ""
6464
if (!binding.hasVariable('RERUN_ITERATIONS')) RERUN_ITERATIONS = "0"
65+
if (!binding.hasVariable('USE_GIT_SSH')) USE_GIT_SSH = false
6566

6667
if (!binding.hasVariable('BUILDS_TO_KEEP')) {
6768
BUILDS_TO_KEEP = 10
@@ -437,6 +438,7 @@ ARCH_OS_LIST.each { ARCH_OS ->
437438
stringParam('SLACK_CHANNEL', SLACK_CHANNEL, "Slack channel. e.g., #rt-jenkins")
438439
booleanParam('PERSONAL_BUILD', false, "Is this a personal build?")
439440
booleanParam('USE_TESTENV_PROPERTIES', USE_TESTENV_PROPERTIES.toBoolean(), "use properties defined in the testenv.properties")
441+
booleanParam('USE_GIT_SSH', USE_GIT_SSH.toBoolean(), "Use ssh protocol? True, if clone all repo by ssh.")
440442
stringParam('RERUN_ITERATIONS', RERUN_ITERATIONS, "Optional. Number of times to repeat execution of failed test target(s).")
441443
}
442444
cpsScm {

0 commit comments

Comments
 (0)