我试图仅克隆最后一次提交,但在詹金斯工作中遇到以下错误:
+ git config credential.username ****
+ git config user.name jenkins
+ git config user.email jenkins@comp.com
+ git remote add origin https://bitbucket.org/base/my-repo.git
[Pipeline] sh
+ GIT_ASKPASS=true
+ git clone -b master --single-branch https://bitbucket.org/base/my-repo --depth=1 --bare ./last_commit
Cloning into bare repository './last_commit'...
fatal: could not read Username for 'https://bitbucket.org': No such device or address
这是我用作Jenkins共享库的功能:
def call(url, branch, gitCredentialId) {
try {
withCredentials([[$class: 'UsernamePasswordMultiBinding', credentialsId: gitCredentialId, usernameVariable: 'GIT_USERNAME', passwordVariable: 'GIT_PASSWORD']]) {
sh("""
git init
git config credential.username ${env.GIT_USERNAME}
git config user.name \"jenkins\"
git config user.email \"jenkins@comp.com\"
git remote add origin ${url}.git
""")
sh(returnStdout: false, script: """
GIT_ASKPASS=true
git clone -b ${branch} --single-branch ${url} --depth=1 --bare ./last_commit
""")
def email = sh(returnStdout: true, script: """
cd ./last_commit
git log -1 --format='%ae'
""")
return email.trim()
}
} finally {
sh """
git config --unset credential.username
git config --unset credential.helper
"""
}
}
我在这里错过了什么?有没有人遇到过同样的问题? 我想做的就是获取最新的提交者电子邮件。
请注意,我在fatal: could not read Username for, No such device
处阅读了此帖子尽管与上述错误相同,但不同之处在于,在该操作中,OP面临已签出代码的错误,他们尝试推送,而我签出代码没有问题(使用git checkout
)。我的问题是我无法克隆存储库,并且没有预先存在的源代码