无法让Jenkins与Git和BitBucket合作

时间:2014-06-24 16:09:35

标签: git jenkins bitbucket

首先,我想说我是詹金斯的新手。也就是说,我的公司要求我研究我们自制的"构建系统,基于一些powershell脚本,到Jenkins。

我们的开发服务器是:

  • Windows 7 Pro
  • GIT中
  • BitBucket上托管的源代码
  • 詹金斯(我写作时的最新版本)。

我按照一堆教程在Jenkins中设置git(URL,exe路径,SSH密钥,Jenkins服务使用正确的用户帐户运行等),我想这是正确的,但是输出日志非常糟糕,我真的不能说。

我向Jenkins添加了一个示例项目,并且需要信息来构建它,因此URL是:

git@bitbucket.org:<company account>/<repository to build>

分支是&#34; **&#34;。

这个脚本运行大约10分钟(如果我运行我的Powershell等效,它的构建时间不到2分钟)并且失败,这是日志:

Building in workspace D:\jenkins\jobs\#project#\workspace
 > C:\Program Files (x86)\Git\cmd\git.exe rev-parse --is-inside-work-tree
Fetching changes from the remote Git repository
 > C:\Program Files (x86)\Git\cmd\git.exe config remote.origin.url git@bitbucket.org:#company#/#project#.git
Cleaning workspace
 > C:\Program Files (x86)\Git\cmd\git.exe rev-parse --verify HEAD
No valid HEAD. Skipping the resetting
 > C:\Program Files (x86)\Git\cmd\git.exe clean -fdx
Fetching upstream changes from git@bitbucket.org:#company#/#project#.git
 > C:\Program Files (x86)\Git\cmd\git.exe --version
using GIT_SSH to set credentials 
 > C:\Program Files (x86)\Git\cmd\git.exe fetch --tags --progress git@bitbucket.org:#company#/#project#.git +refs/heads/*:refs/remotes/origin/*
ERROR: Timeout after 10 minutes
FATAL: Failed to fetch from git@bitbucket.org:#company#/#project#.git
hudson.plugins.git.GitException: Failed to fetch from git@bitbucket.org:#company#/#project#.git
    at hudson.plugins.git.GitSCM.fetchFrom(GitSCM.java:623)
    at hudson.plugins.git.GitSCM.retrieveChanges(GitSCM.java:855)
    at hudson.plugins.git.GitSCM.checkout(GitSCM.java:880)
    at hudson.model.AbstractProject.checkout(AbstractProject.java:1252)
    at hudson.model.AbstractBuild$AbstractBuildExecution.defaultCheckout(AbstractBuild.java:624)
    at jenkins.scm.SCMCheckoutStrategy.checkout(SCMCheckoutStrategy.java:86)
    at hudson.model.AbstractBuild$AbstractBuildExecution.run(AbstractBuild.java:530)
    at hudson.model.Run.execute(Run.java:1732)
    at hudson.model.FreeStyleBuild.run(FreeStyleBuild.java:43)
    at hudson.model.ResourceController.execute(ResourceController.java:88)
    at hudson.model.Executor.run(Executor.java:234)
Caused by: hudson.plugins.git.GitException: Command "C:\Program Files (x86)\Git\cmd\git.exe fetch --tags --progress git@bitbucket.org:#company#/#project#.git +refs/heads/*:refs/remotes/origin/*" returned status code -1:
stdout: 
stderr: 
    at org.jenkinsci.plugins.gitclient.CliGitAPIImpl.launchCommandIn(CliGitAPIImpl.java:1325)
    at org.jenkinsci.plugins.gitclient.CliGitAPIImpl.launchCommandWithCredentials(CliGitAPIImpl.java:1186)
    at org.jenkinsci.plugins.gitclient.CliGitAPIImpl.access$200(CliGitAPIImpl.java:87)
    at org.jenkinsci.plugins.gitclient.CliGitAPIImpl$1.execute(CliGitAPIImpl.java:257)
    at hudson.plugins.git.GitSCM.fetchFrom(GitSCM.java:621)
    ... 10 more

所以,我尝试从项目文件夹运行一个命令提示符,然后手动运行&#34;#34;我在这个日志中看到的每个命令。并且......没有麻烦,一切正常。

最后,我在这里寻求帮助,我有点失落。感谢。

EDIT1 :添加了Quinnly提供的截图。

Jenkins GIT设置 Jenkins GIT settings

示例项目设置 Example projects settings

EDIT2

我试图通过我自己的构建系统和Jenkins构建来自我的示例项目的.git数据。

.git / config文件

从我们自己的系统构建时,此文件包含以下行:

fetch = +refs/heads/master:refs/remotes/origin/master

Jenkins工作区中的相同内容并不包含此数据。此外,在我们自己的系统上,这个文件有一个[branch&#34; master&#34;]部分,有2行&#34; remote&#34;和&#34;合并&#34;。从Jenkins开始,整个部分及其2行不在配置文件中。

1 个答案:

答案 0 :(得分:0)

终于找到了问题。 RSA私钥的路径格式不正确。现在它有效。