jenkins - Jenkins 无法从远程 git 存储库中获取代码
问题描述
我在 ec2 实例中安装了 jenkins。这是我尝试构建的第一个项目我收到错误
FailedConsole Output
Started by user nithinroyal
Running as SYSTEM
Building in workspace /var/lib/jenkins/workspace/demo
[WS-CLEANUP] Deleting project workspace...
[WS-CLEANUP] Deferred wipeout is used...
[WS-CLEANUP] Done
using credential github
Cloning the remote Git repository
Cloning repository https://github.com/nithinkota/demo.git/
> git init /var/lib/jenkins/workspace/demo # timeout=10
ERROR: Error cloning remote repo 'origin'
hudson.plugins.git.GitException: Could not init /var/lib/jenkins/workspace/demo
at org.jenkinsci.plugins.gitclient.CliGitAPIImpl$5.execute(CliGitAPIImpl.java:957)
at org.jenkinsci.plugins.gitclient.CliGitAPIImpl$2.execute(CliGitAPIImpl.java:737)
at hudson.plugins.git.GitSCM.retrieveChanges(GitSCM.java:1105)
at hudson.plugins.git.GitSCM.checkout(GitSCM.java:1145)
at hudson.scm.SCM.checkout(SCM.java:505)
at hudson.model.AbstractProject.checkout(AbstractProject.java:1205)
at hudson.model.AbstractBuild$AbstractBuildExecution.defaultCheckout(AbstractBuild.java:574)
at jenkins.scm.SCMCheckoutStrategy.checkout(SCMCheckoutStrategy.java:86)
at hudson.model.AbstractBuild$AbstractBuildExecution.run(AbstractBuild.java:499)
at hudson.model.Run.execute(Run.java:1853)
at hudson.model.FreeStyleBuild.run(FreeStyleBuild.java:43)
at hudson.model.ResourceController.execute(ResourceController.java:97)
at hudson.model.Executor.run(Executor.java:428)
Caused by: hudson.plugins.git.GitException: Error performing git command: git init /var/lib/jenkins/workspace/demo
at org.jenkinsci.plugins.gitclient.CliGitAPIImpl.launchCommandIn(CliGitAPIImpl.java:2379)
at org.jenkinsci.plugins.gitclient.CliGitAPIImpl.launchCommandIn(CliGitAPIImpl.java:2302)
at org.jenkinsci.plugins.gitclient.CliGitAPIImpl.launchCommandIn(CliGitAPIImpl.java:2298)
at org.jenkinsci.plugins.gitclient.CliGitAPIImpl.launchCommand(CliGitAPIImpl.java:1857)
at org.jenkinsci.plugins.gitclient.CliGitAPIImpl$5.execute(CliGitAPIImpl.java:955)
... 12 more
Caused by: java.io.IOException: Cannot run program "git" (in directory "/var/lib/jenkins/workspace/demo"): error=2, No such file or directory
at java.lang.ProcessBuilder.start(ProcessBuilder.java:1048)
at hudson.Proc$LocalProc.<init>(Proc.java:250)
at hudson.Proc$LocalProc.<init>(Proc.java:219)
at hudson.Launcher$LocalLauncher.launch(Launcher.java:936)
at hudson.Launcher$ProcStarter.start(Launcher.java:454)
at org.jenkinsci.plugins.gitclient.CliGitAPIImpl.launchCommandIn(CliGitAPIImpl.java:2365)
... 16 more
Caused by: java.io.IOException: error=2, No such file or directory
at java.lang.UNIXProcess.forkAndExec(Native Method)
at java.lang.UNIXProcess.<init>(UNIXProcess.java:247)
at java.lang.ProcessImpl.start(ProcessImpl.java:134)
at java.lang.ProcessBuilder.start(ProcessBuilder.java:1029)
... 21 more
ERROR: Error cloning remote repo 'origin'
Finished: FAILURE
在源代码管理步骤中配置项目时,当我添加存储库 url 时以红色显示错误
Failed to connect to repository : Error performing git command: git ls-remote -h https://github.com/nithinkota/demo.git/ HEAD
解决方案
检查,是否安装了 Jenkins Git 插件,是否在System
页面中配置,Path to Git executable
字段。
放入其中C:\Path\to\Git\bin\git.exe
,C:\Path\to\Git
作为您安装Git for Windows的文件夹。
推荐阅读
- python - 类内矩阵乘积定义的问题
- jquery - 更改文本
点击元素 - reactjs - 如何使用reactjs查询此处地图中的路线
- python - 如何在不违反 Liskov 替换的情况下扩展 Python 中的列表数据结构 - 提供属性而不是实例?
- azure - 使用用户名/密码生成不记名令牌以访问 API 端点的可能解决方案
- regex - 使用正则表达式查找方程的截距
- python - 使用 Pandas 和 XLSXWriter 在 Excel 工作表中创建表格
- teamcity - 分支规范问题(构建是在分支 XXX 中触发的,它与构建 VCS 根监控的任何分支都不对应)
- javascript - Angular - 类型“{}”缺少类型“任何 []”中的以下属性
- python-3.x - Unable to joint two geopandas data framesm due to 'rtree' error