簡體   English   中英

Jenkins Windows Slave沒有為git使用正確的憑據

[英]Jenkins Windows Slave not using correct credentials for git

我有一個使用Windows從站構建UWP應用程序的Jenkins主站(ubuntu)。 當它嘗試運行git fetch時,出現以下錯誤:-

git fetch --tags --progress git@gitlab.com:user/repo.git +refs/heads/*:refs/remotes/origin/*
23:24:08 ERROR: Error fetching remote repo 'origin'
23:24:08 hudson.plugins.git.GitException: Failed to fetch from git@gitlab.com:user/repo.git
23:24:08    at hudson.plugins.git.GitSCM.fetchFrom(GitSCM.java:803)
23:24:08    at hudson.plugins.git.GitSCM.retrieveChanges(GitSCM.java:1063)
23:24:08    at hudson.plugins.git.GitSCM.checkout(GitSCM.java:1094)
23:24:08    at hudson.scm.SCM.checkout(SCM.java:495)
23:24:08    at hudson.model.AbstractProject.checkout(AbstractProject.java:1276)
23:24:08    at hudson.model.AbstractBuild$AbstractBuildExecution.defaultCheckout(AbstractBuild.java:560)
23:24:08    at jenkins.scm.SCMCheckoutStrategy.checkout(SCMCheckoutStrategy.java:86)
23:24:08    at hudson.model.AbstractBuild$AbstractBuildExecution.run(AbstractBuild.java:485)
23:24:08    at hudson.model.Run.execute(Run.java:1735)
23:24:08    at hudson.matrix.MatrixRun.run(MatrixRun.java:153)
23:24:08    at hudson.model.ResourceController.execute(ResourceController.java:97)
23:24:08    at hudson.model.Executor.run(Executor.java:405)
23:24:08 Caused by: hudson.plugins.git.GitException: Command "git fetch --tags --progress git@gitlab.com:user/repo.git +refs/heads/*:refs/remotes/origin/*" returned status code 128:
23:24:08 stdout: 
23:24:08 stderr: jenkins_user@gitlab.com: Permission denied (publickey).
23:24:08 fatal: Could not read from remote repository.

似乎使用了錯誤的電子郵件地址來獲取存儲庫。 它應該是jenkins_user@domain.com而不是@ gitlab.com,但是即使我執行git config --global user.email jenkins_user@domain.com它仍然會給出相同的錯誤。

這可能與本地存儲庫中的user.email配置無關。

當jenkins slave作為Windows服務安裝(以確保即使沒有人登錄時代理也可以運行)時,運行jenkins二進制文件的用戶是本地系統帳戶。 您必須創建一個SSH公/私鑰對,並將其放在計算機上的正確文件夾下:

C:\Windows\system32\config\systemprofile\.ssh

您還需要復制一個適當的known_hosts文件,以確保第一個git pull可以正常工作,而無需在命令行上鍵入yes (在jenkins作業中這是不可能的)。

警告:在大多數情況下,Windows Update執行系統升級時,將清除此文件夾,並且您丟失了密鑰。 您必須將文件保存在其他位置,以確保升級后可以將其還原。

有關其他信息,請參閱此帖子 ,或者在您首選的搜索引擎上搜索“ ssh key本地系統帳戶”。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM