7

我有一个 jenkins 实例,它连接了一个 Windows 从机。我还有一个运行在 github 中的作业,并且我设置了触发器 - “将更改推送到 GitHub 时构建”。

当我将更改推送到 github 时,jenkins 上没有触发构建。我检查并看到有效负载确实在“Github 挂钩日志”中转移到了 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 服务以管理员身份登录的位置进行了调整,使其具有所有权限。2.我默认的jenkins服务器是linux机器,从机是windows机器。显然两者都有不同的 git 可执行路径。所以我想知道jenkins是否出于某种原因在我的linux机器上运行这个命令。

我确实有项目设置只能在 Windows 从属盒上运行,并且工作正常,因为它构建良好(因此它能够找到该作业的 git 可执行文件)

任何指针?

还有谁知道jenkins的github插件如何与slave机器一起工作(它是在slave中寻找git还是去jenkins所在的地方,因为这可能是源头,虽然不知道那个奇怪的案例的解决方案是什么?是?)

4

1 回答 1

5

我尝试在 Windows 作业的 git SCM 定义中添加“使用工作区强制轮询”作为“附加行为”。这解决了我的问题 - 不是最好的方法,但有效。

如果轮询在 Linux 节点(主节点)上运行,但不知何故决定它需要使用 Windows git 配置来轮询主节点,这可能会导致 Linux 主节点尝试从 Windows git 位置执行 git,而不是 Linux git位置(这是我的项目中发生的事情)。那将是一个错误,我对这个错误感到惊讶,因为有许多 Jenkins git 安装使用 Linux 和 Windows 从属的广泛混合。我不知道这样的错误,但由于“使用工作区强制轮询”为您解决了问题,它可能暗示这是一个需要更多调查的领域。

于 2014-09-22T19:43:59.980 回答