fatal: could not read Username for 'http:// 解決方案
在部署drone(CICD軟件)後,觸發提交時,drone-runner執行拉取倉庫代碼(在自己部署的gogs上)時出現該問題
Initialized empty Git repository in /drone/src/.git/
+ git fetch origin +refs/heads/master:
fatal: could not read Username for 'http://ip:port': terminal prompts disabled
原因提示爲需要輸入用戶名密碼,但由於這是CICD軟件,並沒有輸入密碼的時機,因此解決方案有兩種:
- 使用 ssh,在drone所在服務器生產 git 公鑰,上傳到代碼託管(我這裏用的自己搭建的 gogs,實際上也會有github、gitea、gitee、gitlab等等),即可不需要用戶名密碼下載上傳
- 使用git的記憶密碼機制保存用戶名密碼
- 進入 drone 所在服務器,使用 drone 進程用戶登錄,進入家目錄(
cd ~
) - 執行
git clone [你的git代碼路徑]
,發現需要輸入密碼,ctrl + c
中斷 - 執行
touch .git-credentials
創建 .git-credentials 文件 - 執行
vim .git-credentials
編輯該文件 - 按 i 鍵進入編輯模式,輸入:
http(s)://{你的用戶名}:{你的密碼}@你的git服務器地址
【注意選擇 https/http,去掉花括號】 - 按
ESC
輸入:wq
保存並退出 - 執行
git config --global credential.helper store
cat ~/.gitconfig
發現多了一項:[credential] helper = store
- 說明已經配置好了,再次
git clone [你的git代碼路徑]
試試,不需要輸入密碼了
- 進入 drone 所在服務器,使用 drone 進程用戶登錄,進入家目錄(
fatal: could not read Username for ‘http://…’ : terminal prompts disabled 問題解決~