【问题标题】:Jenkins Bitbucket LFS-pull failing with missing protocol 'unknown'Jenkins Bitbucket LFS-pull 失败,缺少协议“未知”
【发布时间】:2022-07-05 18:09:27
【问题描述】:
我正在尝试设置一个 Bitbucket-Repo 以在 Jenkins 中构建。
但是,只要 Repo 中有 LFS 文件,拉取就会失败,并显示错误“缺少协议‘未知’”。
“结帐后添加 Git LFS 拉取”会发生这种情况。-行为以及将“git lfs pull”添加到我的管道时。
“git lfs env”进一步表明端点是空的(即使在正常结帐之后)
是否有我遗漏的设置步骤?
【问题讨论】:
标签:
git
jenkins
bitbucket
git-lfs
【解决方案1】:
在jenkinsci/bitbucket-branch-source-plugin issue 593,OP 报告:
我终于设法解决了这个问题。
- 我向 Jenkins 添加了一组“普通”凭据(用户名和应用程序密码)。
- 然后,当拉(结帐 scm)时,我跳过 LFS。
- 之后,我将
lfs-url 设置为使用用户名和应用密码的那个,然后使用这些设置LFS pull:
sh 'git lfs install --skip-smudge' // Required because LFS is currently failing
script {
def scmVars = checkout scm
// Workaround for LFS: Manually set the LFS-URL using Username & App Password, then do a pull using those instead of the OAuth
// Remove everything up to @bitbucket.org from the Git URL (strip out the Bitbucket OAuth-credentials)
echo "Performing LFS-Workaround to fix issue with LFS not working when using OAuth-credentials"
def partialURL = sh(returnStdout: true, script: """echo $scmVars.GIT_URL | sed -e 's/https:\\/\\/.*:.*@bitbucket.org//'""")
partialURL = partialURL.replace('\0', '').replace('\n', '') // Remove Null-Char & End-Line
withCredentials([usernamePassword(credentialsId: 'Bitbucket_Basic', passwordVariable: 'BB_APP_PASS', usernameVariable: 'BB_USER')]) {
// Generate new LFS-URL using Username & App-Password
def LFSUrl = 'https://$BB_USER:$BB_APP_PASS@bitbucket.org' + partialURL + '/info/lfs'
sh "git config lfs.url ${LFSUrl}" // Set as LFS-URL for the pull
sh 'git lfs pull' // Pull LFS-files using workaround-config
}
}
您还有其他LFS exclusion options,但在这种情况下--skip-smudge 就足够了。