我有一个 jenkins 实例,它连接了一个 Windows 从机。我还有一个驻留在 github 中的作业正在运行,并且我有触发器 - “将更改推送到 GitHub 时构建”设置。
当我将更改推送到 github 时,jenkins 上没有触发构建。我在“Github Hook 日志”中检查并发现有效负载确实已转移到 jenkins,但出现以下错误:
Started on Sep 18, 2014 3:57:06 PM
Using strategy: Default
[poll] Last Built Revision: Revision ce6a183e834a3e31afa0eb83a4418b0619c8642b (origin/master)
> "C:\Program Files (x86)\Git\cmd\git.exe" ls-remote -h https://xx/xx/xx master # timeout=10
FATAL: hudson.plugins.git.GitException: Error performing command: "C:\Program Files (x86)\Git\cmd\git.exe" ls-remote -h https://xx/xx/xx master
hudson.util.IOException2: hudson.plugins.git.GitException: Error performing command: "C:\Program Files (x86)\Git\cmd\git.exe" ls-remote -h https://xx/xx/xx master
at hudson.plugins.git.GitSCM.compareRemoteRevisionWith(GitSCM.java:462)
at hudson.scm.SCM._compareRemoteRevisionWith(SCM.java:357)
at hudson.scm.SCM.poll(SCM.java:374)
at hudson.model.AbstractProject._poll(AbstractProject.java:1428)
at hudson.model.AbstractProject.poll(AbstractProject.java:1331)
at com.cloudbees.jenkins.GitHubPushTrigger$1.runPolling(GitHubPushTrigger.java:73)
at com.cloudbees.jenkins.GitHubPushTrigger$1.run(GitHubPushTrigger.java:98)
at hudson.util.SequentialExecutionQueue$QueueEntry.run(SequentialExecutionQueue.java:118)
at jenkins.util.ContextResettingExecutorService$1.run(ContextResettingExecutorService.java:28)
at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:471)
at java.util.concurrent.FutureTask.run(FutureTask.java:262)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
at java.lang.Thread.run(Thread.java:744)
Caused by: hudson.plugins.git.GitException: Error performing command: "C:\Program Files (x86)\Git\cmd\git.exe" ls-remote -h https://xx/xx/xx master
at org.jenkinsci.plugins.gitclient.CliGitAPIImpl.launchCommandIn(CliGitAPIImpl.java:1444)
at org.jenkinsci.plugins.gitclient.CliGitAPIImpl.launchCommandWithCredentials(CliGitAPIImpl.java:1225)
at org.jenkinsci.plugins.gitclient.CliGitAPIImpl.launchCommandWithCredentials(CliGitAPIImpl.java:1138)
at org.jenkinsci.plugins.gitclient.CliGitAPIImpl.launchCommandWithCredentials(CliGitAPIImpl.java:1129)
at org.jenkinsci.plugins.gitclient.CliGitAPIImpl.getHeadRev(CliGitAPIImpl.java:2059)
at hudson.plugins.git.GitSCM.compareRemoteRevisionWithImpl(GitSCM.java:495)
at hudson.plugins.git.GitSCM.compareRemoteRevisionWith(GitSCM.java:460)
... 13 more
Caused by: java.io.IOException: Cannot run program ""C:\Program Files (x86)\Git\cmd\git.exe"": error=2, No such file or directory
at java.lang.ProcessBuilder.start(ProcessBuilder.java:1041)
at hudson.Proc$LocalProc.<init>(Proc.java:244)
at hudson.Proc$LocalProc.<init>(Proc.java:216)
at hudson.Launcher$LocalLauncher.launch(Launcher.java:780)
at hudson.Launcher$ProcStarter.start(Launcher.java:360)
at org.jenkinsci.plugins.gitclient.CliGitAPIImpl.launchCommandIn(CliGitAPIImpl.java:1433)
... 19 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:135)
at java.lang.ProcessImpl.start(ProcessImpl.java:130)
at java.lang.ProcessBuilder.start(ProcessBuilder.java:1022)
... 24 more
基本上是提示无法运行命令 C:\Program Files (x86)\Git\cmd\git.exe"ls-remote -h https://xx/xx/xx master
但是当我手动进入我的从机并运行命令时,它工作正常。
请注意 1.我调整了jenkins slave service以admin登录的地方,让它拥有所有的权限。 2.我默认的jenkins server是linux box,slave机器是windows box。显然两者都有不同的 git 可执行路径。所以我想知道 jenkins 是否出于某种原因在我的 linux 机器上运行了这个命令。
我确实有项目设置只在 Windows 从机上运行并且工作正常,因为它构建良好(因此它能够找到工作的 git 可执行文件)
有什么建议吗?
还有谁知道 jenkins 的 github 插件如何与从属机器一起工作(它是在从属机器中寻找 git 还是去 jenkins 所在的地方,因为这可能是来源,但不知道解决方案是什么奇怪的情况会是什么?)
最佳答案
我尝试在我的 Windows 作业的 git SCM 定义中添加“使用工作区强制轮询”作为“附加行为”。这解决了我的问题 - 不是最好的方法但有效。
如果轮询在 Linux 节点(master)上运行,但不知何故决定它需要使用 Windows git 配置来轮询 master,这可能会导致 Linux master 尝试从 Windows git 位置执行 git,而不是Linux git 位置(这是我的项目中发生的事情)。那将是一个错误,我对这个错误感到惊讶,因为有许多 Jenkins git 安装使用了 Linux 和 Windows 从服务器的广泛组合。 我不知道有这样的错误,但由于“使用工作区强制轮询”为您解决了这个问题,它可能暗示这是一个需要进行更多调查的领域。
关于Github-Jenkins 触发奴隶问题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/25917812/