From 3bf47dca9f55f8e02dc69a67e832e3b696ba7acc Mon Sep 17 00:00:00 2001 From: Brian Herrera Date: Thu, 25 Mar 2021 15:33:04 -0700 Subject: [PATCH] Run git lfs in a separate step. (#3) Run git lfs in a separate step. Jenkins is unable to load the credentials for the custom LFS endpoint. Command works locally but it's unable use the credential manager within Jenkins. --- AutomatedReview/Jenkinsfile | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/AutomatedReview/Jenkinsfile b/AutomatedReview/Jenkinsfile index 578112c435..0a3d4ad7e9 100644 --- a/AutomatedReview/Jenkinsfile +++ b/AutomatedReview/Jenkinsfile @@ -271,7 +271,18 @@ def PullFilesFromGit(String filenamePath, String branchName, boolean failIfNotFo } } +def SetLfsCredentials(cmd, lbl = '') { + if (env.IS_UNIX) { + sh label: lbl, + script: cmd + } else { + bat label: lbl, + script: cmd + } +} + def CheckoutRepo(boolean disableSubmodules = false) { + 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, @@ -318,6 +329,14 @@ def CheckoutRepo(boolean disableSubmodules = false) { } } + // 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'