@@ -38,15 +38,29 @@ def createKubernetesPodConfig()
3838    return  podConfig
3939}
4040
41+ def  getGitCredentialId  (String  repoUrl ) {
42+     if  (repoUrl ==~  / https:\/\/ github\. com\/ [\w\- ]+\/ [\w\-\. ]+(\. git)?/ 
43+         return  ' github-token-trtllm-ci' 
44+     }
45+     if  (repoUrl ==~  / https:\/\/ gitlab\- master\. nvidia\. com\/ [\w\- ]+\/ [\w\-\. ]+(\. git)?/ 
46+         return  ' svc_tensorrt_gitlab_api_token' 
47+     }
48+     return  null 
49+ }
50+ 
4151def  generate ()
4252{
4353    sh " pwd && ls -alh" 
4454
4555    container(" alpine" 
46-         LLM_REPO  =  params. repoUrl
56+         def   LLM_REPO  =  params. repoUrl
4757        if  (LLM_REPO  ==  " Custom Repo" 
4858            LLM_REPO  =  params. customRepoUrl
4959        }
60+         def  CREDENTIAL_ID  =  getGitCredentialId(LLM_REPO )
61+         if  (CREDENTIAL_ID  ==  null ) {
62+             throw  new  Exception (" Failed to get access token for repository" 
63+         }
5064        sh " apt update" 
5165        sh " apt install -y python3-dev git curl git-lfs" 
5266        sh " git config --global --add safe.directory ${ env.WORKSPACE} " 
@@ -66,7 +80,7 @@ def generate()
6680            sh " git status" 
6781            sh " git add \$ (find . -type f \\ ( -name 'poetry.lock' -o -name 'pyproject.toml' \\ ))" 
6882            sh " git commit -s -m \" [None][infra] Check in most recent lock file from nightly pipeline\" " 
69-             withCredentials([usernamePassword(credentialsId : ' github-cred-trtllm-ci ' usernameVariable : ' GIT_USER' passwordVariable : ' GIT_PASS' 
83+             withCredentials([usernamePassword(credentialsId : CREDENTIAL_ID , usernameVariable : ' GIT_USER' passwordVariable : ' GIT_PASS' 
7084                def  authedUrl =  LLM_REPO . replaceFirst(' https://' " https://${ GIT_USER} ${ GIT_PASS} " 
7185                sh " git remote set-url origin ${ authedUrl} " 
7286                sh " git fetch origin ${ params.branchName} " 
0 commit comments