Skip to content

Commit

Permalink
Support clone all repo by ssh protocol in testJob (#4228)
Browse files Browse the repository at this point in the history
  • Loading branch information
Accelerator1996 committed Jan 29, 2023
1 parent 7fc91a2 commit 46e205a
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 0 deletions.
18 changes: 18 additions & 0 deletions buildenv/jenkins/JenkinsfileBase
Original file line number Diff line number Diff line change
Expand Up @@ -141,6 +141,15 @@ def setupEnv() {
} else {
sh 'printenv'
}
if ( params.USE_GIT_SSH ) {
def gitGlobalConfig = fileExists('~/.gitconfig') ? sh(script:"git config --global -l", returnStdout:true) : ''
if (!gitGlobalConfig || !gitGlobalConfig.contains('[email protected]:.insteadof')) {
sh "git config --global url.'[email protected]:'.insteadOf 'https://github.com/'"
}
if (!gitGlobalConfig.contains('[email protected]:.insteadof')) {
sh "git config --global url.'[email protected]:'.insteadOf 'https://gitlab.com/'"
}
}
}

def setupParallelEnv() {
Expand Down Expand Up @@ -805,6 +814,15 @@ def testBuild() {
sh "find /tmp -name '*core*' -print 2>/dev/null -exec rm -f {} \\; || true"
}
}
if ( params.USE_GIT_SSH ) {
def gitGlobalConfig = sh(script:"git config --global -l", returnStdout:true)
if (gitGlobalConfig.contains('[email protected]:.insteadof')) {
sh "git config --global --unset url.'[email protected]:'.insteadOf"
}
if (gitGlobalConfig.contains('[email protected]:.insteadof')) {
sh "git config --global --unset url.'[email protected]:'.insteadOf"
}
}
}
}
}
Expand Down
2 changes: 2 additions & 0 deletions buildenv/jenkins/testJobTemplate
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@ if (!binding.hasVariable('USER_CREDENTIALS_ID')) USER_CREDENTIALS_ID = ""
if (!binding.hasVariable('GENERATE_JOBS')) GENERATE_JOBS = false
if (!binding.hasVariable('CLOUD_PROVIDER')) CLOUD_PROVIDER = ""
if (!binding.hasVariable('RERUN_ITERATIONS')) RERUN_ITERATIONS = "0"
if (!binding.hasVariable('USE_GIT_SSH')) USE_GIT_SSH = false

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

0 comments on commit 46e205a

Please sign in to comment.