我在jenkins中有Github Organisation
項目。在我的版本庫的根,我的Jenkinsfile
看起來是這樣的:如何結帳github組織中的ssh remote Jenkins工作流程並在Jenkinsfile中使用ssh憑證
node {
def jenkinsCredsId = 'xxxxxxxx-yyyy-zzzz-aaaa-bbbbbbbbbbbb'
stage 'Checkout'
checkout scm
// I also tried the following:
// checkout scm: [$class: 'GitSCM', source: 'ssh://[email protected]:MY_ORGANISATION/jenkins-testing-temp.git', clean: true, credentialsId: jenkinsCredsId]
stage 'Build'
// generate some artefact (dist.zip)
stage 'Release'
sshagent([jenkinsCredsId]) {
sh '''
git remote -v // show remotes
ssh-add -l // show currently loaded ssh keys fingerprints
git fetch --all --tags // IT FAILS HERE
CURRENT_BUILD_TAG="some_build/${BUILD_NUMBER}"
git tag ${CURRENT_BUILD_TAG}
git push --tags
github-release release \
--security-token ${GITHUB_RELEASE_TOKEN} \
--user MY_ORGANIZATION \
--repo MY_REPO \
--tag ${CURRENT_BUILD_TAG} \
--name ${CURRENT_BUILD_TAG}
github-release upload \
--security-token ${GITHUB_RELEASE_TOKEN} \
--user MY_ORGANIZATION \
--repo MY_REPO \
--tag ${CURRENT_BUILD_TAG} \
--name ${CURRENT_BUILD_TAG} \
--file dist.zip
'''
}
有一個在這裏的幾行測試存儲庫訪問和它目前沒有在git fetch
部分,出現以下錯誤:
fatal: could not read Username for ' https://github.com ': No such device or address
上述Jenkinsfile
的git remote -v
命令輸出類似origin https://github.com/MY_ORGANIZATION/MY_REPO
的東西。
我Github Organization
git的配置看起來是這樣的:
我發現了幾個相關問題: