![](/img/trans.png)
[英]Jenkins Git Plugin with Git LFS fails with 'Bad Credentials' on Mac slave
[英]Jenkins git checkout freezing on credentials for LFS
我有一個基於 Jenkins 文件的多分支管道,該文件顯式克隆了參數提供的另一個存儲庫。 在嘗試作為git checkout -f <HASH>
命令的一部分請求git-lfs
的憑據后,我看到它正在凍結並超時。
如何簽出具有憑據 git lfs 訪問權限的存儲庫?
詹金斯文件:
stages {
stage('Fetch Source Code') {
steps{
dir('repo') {
git branch: "${params.Branch}", credentialsId: 'git-creds', url: "${params.RepoURL}"
}
}
}
Jenkins 控制台:
> git init /home/jenkins/agent/workspace/<PIPELINE_NAME>/repo # timeout=10
Fetching upstream changes from <HTTPS_PRIVATE_GITLAB_URL>
> git --version # timeout=10
> git --version # 'git version 2.30.2'
using GIT_ASKPASS to set credentials Credentials to access git resources
> git fetch --tags --force --progress -- <HTTPS_PRIVATE_GITLAB_URL> +refs/heads/*:refs/remotes/origin/* # timeout=10
Avoid second fetch
Checking out Revision HASH (refs/remotes/origin/master)
> git config remote.origin.url <HTTPS_PRIVATE_GITLAB_URL> # timeout=10
> git config --add remote.origin.fetch +refs/heads/*:refs/remotes/origin/* # timeout=10
> git rev-parse refs/remotes/origin/master^{commit} # timeout=10
> git config core.sparsecheckout # timeout=10
> git checkout -f <HASH> # timeout=10
Times out
經過足夠的調試。 我發現發生了什么事。
默認情況下,Git 插件不會為大多數 git 命令提供憑據(僅獲取它出現),因此當它執行checkout
時,它會凍結等待憑據訪問 LFS。
通過良好的設計,盡管令我沮喪的是,git/jenkins 不會將密碼保存在機器上的任何位置,並且 LFS 對象作為獲取的一部分被下載。 設置 Jenkins 在結帳后執行 LFS 拉取並不能解決問題,因為它試圖在結帳期間執行 LFS 拉取。
解決方案是在全局環境變量中設置GIT_LFS_SKIP_SMUDGE=1
並在結帳步驟中添加 LFS pull 以顯式拉入 LFS 對象。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.