Skip to content

Commit 8316779

Browse files
committed
add logic to get the correct credential id
Signed-off-by: Yuanjing Xue <[email protected]>
1 parent dd4c427 commit 8316779

File tree

1 file changed

+16
-2
lines changed

1 file changed

+16
-2
lines changed

jenkins/GenerateLock.groovy

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -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+
4151
def 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

Comments
 (0)