Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support clone all repo by ssh protocol in testJob (#4228) #4229

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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')) {

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think overwriting should be fine, no need to check for this condition. Or even better, do git config --local ... to install the preferences on the current cloned directory (Jenkins workspace for the current build)

Local (repository) level configs take precedence over global ones.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think overwriting should be fine, no need to check for this condition. Or even better, do git config --local ... to install the preferences on the current cloned directory (Jenkins workspace for the current build)

Local (repository) level configs take precedence over global ones.

But --local can only be used inside a git repository. So I think --global can affects all git downloads.

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
4 changes: 3 additions & 1 deletion 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 @@ -372,7 +373,7 @@ ARCH_OS_LIST.each { ARCH_OS ->
sectionHeader('Additional test parameters if you want to append or replace options, or repeat the test for more than 1 iteration.')
sectionHeaderStyle(sectionHeaderHelpTextStyleCss)
}
choiceParam('TEST_FLAG', ['', 'JITAAS', 'AOT', 'FIPS'], "Optional. Only set for feature testing. (i.e., JITAAS, AOT, FIPS, etc)")
choiceParam('TEST_FLAG', ['', 'JITAAS', 'AOT', 'FIPS', 'Dragonwell_Standard'], "Optional. Only set for feature testing. (i.e., JITAAS, AOT, FIPS, etc)")
stringParam('EXTRA_OPTIONS', "", "Use this to append options to the test command")
stringParam('JVM_OPTIONS', "", "Use this to replace the test original command line options")
stringParam('APPLICATION_OPTIONS', "", "Use this to append options to the test application")
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