From 84c42018c711beaa172d43fed6861f256e5d988c Mon Sep 17 00:00:00 2001 From: shiranj Date: Fri, 9 Apr 2021 17:37:25 -0700 Subject: [PATCH] Revert AutomatedReview/Jenkinsfile --- AutomatedReview/Jenkinsfile | 132 +++++++++++++++++++----------------- 1 file changed, 70 insertions(+), 62 deletions(-) diff --git a/AutomatedReview/Jenkinsfile b/AutomatedReview/Jenkinsfile index 348152d2e7..8cf7a62726 100644 --- a/AutomatedReview/Jenkinsfile +++ b/AutomatedReview/Jenkinsfile @@ -16,7 +16,7 @@ INCREMENTAL_BUILD_SCRIPT_PATH = 'scripts/build/bootstrap/incremental_build_util. EMPTY_JSON = readJSON text: '{}' -ENGINE_REPOSITORY_NAME = env.DEFAULT_REPOSITORY_NAME +ENGINE_REPOSITORY_NAME = 'o3de' def pipelineProperties = [] @@ -325,17 +325,19 @@ def CheckoutBootstrapScripts(String branchName) { } def CheckoutRepo(boolean disableSubmodules = false) { - palSh('git lfs uninstall', 'Git LFS Uninstall') // Prevent git from pulling lfs objects during checkout + dir(ENGINE_REPOSITORY_NAME) { + palSh('git lfs uninstall', 'Git LFS Uninstall') // Prevent git from pulling lfs objects during checkout - if(fileExists('.git')) { - // If the repository after checkout is locked, likely we took a snapshot while git was running, - // to leave the repo in a usable state, garbagecollect. This also helps in situations where - def indexLockFile = '.git/index.lock' - if(fileExists(indexLockFile)) { - palSh('git gc', 'Git GarbageCollect') - } - if(fileExists(indexLockFile)) { // if it is still there, remove it - palRm(indexLockFile) + if(fileExists('.git')) { + // If the repository after checkout is locked, likely we took a snapshot while git was running, + // to leave the repo in a usable state, garbagecollect. This also helps in situations where + def indexLockFile = '.git/index.lock' + if(fileExists(indexLockFile)) { + palSh('git gc', 'Git GarbageCollect') + } + if(fileExists(indexLockFile)) { // if it is still there, remove it + palRm(indexLockFile) + } } } @@ -348,41 +350,52 @@ def CheckoutRepo(boolean disableSubmodules = false) { retryAttempt = retryAttempt + 1 if(params.PULL_REQUEST_ID) { // This is a pull request build. Perform merge with destination branch before building. - checkout scm: [ - $class: 'GitSCM', - branches: scm.branches, - extensions: [ - [$class: 'PreBuildMerge', options: [mergeRemote: 'origin', mergeTarget: params.DESTINATION_BRANCH]], - [$class: 'SubmoduleOption', disableSubmodules: disableSubmodules, recursiveSubmodules: true], - [$class: 'CheckoutOption', timeout: 60] - ], - userRemoteConfigs: scm.userRemoteConfigs - ] + dir(ENGINE_REPOSITORY_NAME) { + checkout scm: [ + $class: 'GitSCM', + branches: scm.branches, + extensions: [ + [$class: 'PreBuildMerge', options: [mergeRemote: 'origin', mergeTarget: params.DESTINATION_BRANCH]], + [$class: 'SubmoduleOption', disableSubmodules: disableSubmodules, recursiveSubmodules: true], + [$class: 'CheckoutOption', timeout: 60] + ], + userRemoteConfigs: scm.userRemoteConfigs + ] + } } else { - checkout scm: [ - $class: 'GitSCM', - branches: scm.branches, - extensions: [ - [$class: 'SubmoduleOption', disableSubmodules: disableSubmodules, recursiveSubmodules: true], - [$class: 'CheckoutOption', timeout: 60] - ], - userRemoteConfigs: scm.userRemoteConfigs - ] + dir(ENGINE_REPOSITORY_NAME) { + checkout scm: [ + $class: 'GitSCM', + branches: scm.branches, + extensions: [ + [$class: 'SubmoduleOption', disableSubmodules: disableSubmodules, recursiveSubmodules: true], + [$class: 'CheckoutOption', timeout: 60] + ], + userRemoteConfigs: scm.userRemoteConfigs + ] + } } } - // Run lfs in a separate step. Jenkins is unable to load the credentials for the custom LFS endpoint - withCredentials([usernamePassword(credentialsId: "${env.GITHUB_USER}", passwordVariable: 'accesstoken', usernameVariable: 'username')]) { - SetLfsCredentials("git config -f .lfsconfig lfs.url https://${username}:${accesstoken}@${env.LFS_URL}", 'Set credentials') + // Add folder where we will store the 3rdParty downloads and packages + if(!fileExists('3rdParty')) { + palMkdir('3rdParty') } - palSh('git lfs install', 'Git LFS Install') - palSh('git lfs pull', 'Git LFS Pull') - // CHANGE_ID is used by some scripts to identify uniquely the current change (usually metric jobs) - palSh('git rev-parse HEAD > commitid', 'Getting commit id') - env.CHANGE_ID = readFile file: 'commitid' - env.CHANGE_ID = env.CHANGE_ID.trim() - palRm('commitid') + dir(ENGINE_REPOSITORY_NAME) { + // Run lfs in a separate step. Jenkins is unable to load the credentials for the custom LFS endpoint + withCredentials([usernamePassword(credentialsId: "${env.GITHUB_USER}", passwordVariable: 'accesstoken', usernameVariable: 'username')]) { + SetLfsCredentials("git config -f .lfsconfig lfs.url https://${username}:${accesstoken}@${env.LFS_URL}", 'Set credentials') + } + palSh('git lfs install', 'Git LFS Install') + palSh('git lfs pull', 'Git LFS Pull') + + // CHANGE_ID is used by some scripts to identify uniquely the current change (usually metric jobs) + palSh('git rev-parse HEAD > commitid', 'Getting commit id') + env.CHANGE_ID = readFile file: 'commitid' + env.CHANGE_ID = env.CHANGE_ID.trim() + palRm('commitid') + } } def PreBuildCommonSteps(Map pipelineConfig, String projectName, String pipeline, String branchName, String platform, String buildType, String workspace, boolean mount = true, boolean disableSubmodules = false) { @@ -423,33 +436,28 @@ def PreBuildCommonSteps(Map pipelineConfig, String projectName, String pipeline, } dir(workspace) { - // Add folder where we will store the 3rdParty downloads and packages - if(!fileExists('3rdParty')) { - palMkdir('3rdParty') - } - } - - dir("${workspace}/${ENGINE_REPOSITORY_NAME}") { CheckoutRepo(disableSubmodules) // Get python - if(env.IS_UNIX) { - sh label: 'Getting python', - script: 'python/get_python.sh' - } else { - bat label: 'Getting python', - script: 'python/get_python.bat' - } - - if(env.CLEAN_OUTPUT_DIRECTORY.toBoolean() || env.CLEAN_ASSETS.toBoolean()) { - def command = "${pipelineConfig.BUILD_ENTRY_POINT} --platform ${platform} --type clean" - if (env.IS_UNIX) { - sh label: "Running ${platform} clean", - script: "${pipelineConfig.PYTHON_DIR}/python.sh -u ${command}" + dir(ENGINE_REPOSITORY_NAME) { + if(env.IS_UNIX) { + sh label: 'Getting python', + script: 'python/get_python.sh' } else { - bat label: "Running ${platform} clean", - script: "${pipelineConfig.PYTHON_DIR}/python.cmd -u ${command}".replace('/','\\') + bat label: 'Getting python', + script: 'python/get_python.bat' + } + + if(env.CLEAN_OUTPUT_DIRECTORY.toBoolean() || env.CLEAN_ASSETS.toBoolean()) { + def command = "${pipelineConfig.BUILD_ENTRY_POINT} --platform ${platform} --type clean" + if (env.IS_UNIX) { + sh label: "Running ${platform} clean", + script: "${pipelineConfig.PYTHON_DIR}/python.sh -u ${command}" + } else { + bat label: "Running ${platform} clean", + script: "${pipelineConfig.PYTHON_DIR}/python.cmd -u ${command}".replace('/','\\') + } } } }