diff --git a/AutomatedReview/Jenkinsfile b/AutomatedReview/Jenkinsfile index 0a3d4ad7e9..20aada9fc6 100644 --- a/AutomatedReview/Jenkinsfile +++ b/AutomatedReview/Jenkinsfile @@ -114,9 +114,11 @@ def RegexMatcher(str, regex) { return matcher ? matcher.group(1) : null } -def LoadPipelineConfig(String pipelineName, String branchName) { +def LoadPipelineConfig(String pipelineName, String branchName, String scmType) { echo 'Loading pipeline config' - PullFilesFromGit(PIPELINE_CONFIG_FILE, branchName) + if (scmType == 'codecommit') { + PullFilesFromGit(PIPELINE_CONFIG_FILE, branchName) + } def pipelineConfig = {} pipelineConfig = readJSON file: PIPELINE_CONFIG_FILE pipelineConfig.platforms = EMPTY_JSON @@ -128,7 +130,9 @@ def LoadPipelineConfig(String pipelineName, String branchName) { platform_regex = platform_regex.replace('/','\\\\') } echo "Downloading platform pipeline configs ${pipeline_config}" - PullFilesFromGit(pipeline_config, branchName) + if (scmType == 'codecommit') { + PullFilesFromGit(pipeline_config, branchName) + } echo "Searching platform pipeline configs in ${pipeline_config} using ${platform_regex}" for (pipeline_config_path in findFiles(glob: pipeline_config)) { echo "\tFound platform pipeline config ${pipeline_config_path}" @@ -147,7 +151,9 @@ def LoadPipelineConfig(String pipelineName, String branchName) { platform_regex = platform_regex.replace('/','\\\\') } echo "Downloading configs ${build_config}" - PullFilesFromGit(build_config, branchName) + if (scmType == 'codecommit') { + PullFilesFromGit(build_config, branchName) + } echo "Searching configs in ${build_config} using ${platform_regex}" for (build_config_path in findFiles(glob: build_config)) { echo "\tFound config ${build_config_path}" @@ -167,6 +173,16 @@ def GetPipelineRegion() { return pipelineRegion } +def GetSCMType() { + def gitUrl = scm.getUserRemoteConfigs()[0].getUrl() + if (gitUrl ==~ /https:\/\/git-codecommit.*/) { + return 'codecommit' + } else if (gitUrl ==~ /https:\/\/github.com.*/) { + return 'github' + } + return 'unknown' +} + def GetBuildEnvVars(Map platformEnv, Map buildTypeEnv, String pipelineName) { def envVarMap = [:] platformPipelineEnv = platformEnv['ENV'] ?: [:] @@ -185,6 +201,28 @@ def GetBuildEnvVars(Map platformEnv, Map buildTypeEnv, String pipelineName) { return envVarMap } +def CheckoutBootstrapScripts(String branchName) { + checkout([$class: "GitSCM", + branches: [[name: "*/${branchName}"]], + doGenerateSubmoduleConfigurations: false, + extensions: [ + [ + $class: "SparseCheckoutPaths", + sparseCheckoutPaths: [ + [ $class: "SparseCheckoutPath", path: "AutomatedReview/" ], + [ $class: "SparseCheckoutPath", path: "scripts/build/bootstrap/" ], + [ $class: "SparseCheckoutPath", path: "Tools/build/JenkinsScripts/build/Platform" ] + ] + ], + [ + $class: "CloneOption", depth: 1, noTags: false, reference: "", shallow: true + ] + ], + submoduleCfg: [], + userRemoteConfigs: scm.userRemoteConfigs + ]) +} + def GetEnvStringList(Map envVarMap) { def strList = [] envVarMap.each { var -> @@ -473,6 +511,7 @@ try { timestamps { pipelineName = GetRunningPipelineName(env.JOB_NAME) // env.JOB_NAME is the name of the job given by Jenkins pipelineRegion = GetPipelineRegion() + scmType = GetSCMType() if(env.BRANCH_NAME) { branchName = env.BRANCH_NAME @@ -484,8 +523,12 @@ try { echo "Running \"${pipelineName}\" for \"${branchName}\", region: \"${pipelineRegion}\"..." + if (scmType == 'github') { + CheckoutBootstrapScripts(branchName) + } + // Load configs - pipelineConfig = LoadPipelineConfig(pipelineName, branchName) + pipelineConfig = LoadPipelineConfig(pipelineName, branchName, scmType) // Add each platform as a parameter that the user can disable if needed pipelineConfig.platforms.each { platform -> @@ -495,7 +538,9 @@ try { properties(pipelineProperties) // Stash the INCREMENTAL_BUILD_SCRIPT_PATH since all nodes will use it - PullFilesFromGit(INCREMENTAL_BUILD_SCRIPT_PATH, branchName) + if (scmType == 'codecommit') { + PullFilesFromGit(INCREMENTAL_BUILD_SCRIPT_PATH, branchName) + } stash name: 'incremental_build_script', includes: INCREMENTAL_BUILD_SCRIPT_PATH }