简体   繁体   English

Bitbucket Hook因Jenkins项目而失败

[英]Bitbucket Hook fails for Jenkins Project

I'm trying to build a Jenkins Project from a Bitbucket Repository. 我正在尝试从Bitbucket存储库构建Jenkins项目。 Those builds should be executed on every push. 这些构建应该在每次推送时执行。 Jenkins is set up on my local computer. Jenkins已在我的本地计算机上设置。

I've set up port forwarding so Jenkins can be used from my external IP address. 我已经设置了端口转发,以便可以从我的外部IP地址使用Jenkins。

I've install the Bitbucket Plugin for Jenkins: https://wiki.jenkins-ci.org/display/JENKINS/BitBucket+Plugin 我已经安装了Jenkins的Bitbucket插件: https : //wiki.jenkins-ci.org/display/JENKINS/BitBucket+Plugin

I configured my project with the following settings: SCM: Git: 我使用以下设置配置了项目:SCM:Git:

Repository URL: https://$BitbucketUserName:BitbucketPasswort@bitbucket.org/mycompany/projectname.git
Credentials: Bitbucket Username und Pw
Branch Specifier: **master/

Build Triggers: 构建触发器:

Build when a change is pushed to Bitbucket checked
Poll SCM: */1 * * * * 

Bitbucket: Went to the Project - Webhooks. Bitbucket:参加了该项目-Webhooks。

Title: Jenkins
Url: http://myExternalIp:PortforwardingPort/bitbucket-hook/
Active Checked
Triggers: Repository push checked

When I push to that Repository I can see that I'm getting a 200 Response (Successfull post to Jenkins). 当我推送到该存储库时,我可以看到收到200响应(成功发布到Jenkins)。

The Bitbucket Push Log shows following exception: Bitbucket推送日志显示以下异常:

Polling SCM changes on master
Using strategy: Default
 > git rev-parse --is-inside-work-tree # timeout=10
Fetching changes from the remote Git repositories
 > git config remote.origin.url https://username:pw@bitbucket.org/company/projectname.git # timeout=10
Fetching upstream changes from https://username@bitbucket.org/company/projectname.git
 > git --version # timeout=10
using .gitcredentials to set credentials
 > git config --local credential.username username # timeout=10
 > git config --local credential.helper store --file=/Users/Shared/Jenkins/tmp/git7517617021208566630.credentials # timeout=10
 > git -c core.askpass=true fetch --tags --progress https://username@bitbucket.org/companyname/projectname.git +refs/heads/*:refs/remotes/origin/*
ERROR: Timeout after 10 minutes
 > git config --local --remove-section credential # timeout=10
FATAL: hudson.plugins.git.GitException: Failed to fetch from https://username@bitbucket.org/company/project.git
hudson.util.IOException2: hudson.plugins.git.GitException: Failed to fetch from https://user@bitbucket.org/company/project.git
    at hudson.plugins.git.GitSCM.compareRemoteRevisionWith(GitSCM.java:573)
    at hudson.scm.SCM.compareRemoteRevisionWith(SCM.java:381)
    at hudson.scm.SCM.poll(SCM.java:398)
    at hudson.model.AbstractProject.pollWithWorkspace(AbstractProject.java:1468)
    at hudson.model.AbstractProject._poll(AbstractProject.java:1438)
    at hudson.model.AbstractProject.poll(AbstractProject.java:1349)
    at com.cloudbees.jenkins.plugins.BitBucketTrigger$1.runPolling(BitBucketTrigger.java:62)
    at com.cloudbees.jenkins.plugins.BitBucketTrigger$1.run(BitBucketTrigger.java:87)
    at hudson.util.SequentialExecutionQueue$QueueEntry.run(SequentialExecutionQueue.java:119)
    at jenkins.util.ContextResettingExecutorService$1.run(ContextResettingExecutorService.java:28)
    at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511)
    at java.util.concurrent.FutureTask.run(FutureTask.java:266)
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
    at java.lang.Thread.run(Thread.java:745)
Caused by: hudson.plugins.git.GitException: Failed to fetch from https://user@bitbucket.org/company/project.git
    at hudson.plugins.git.GitSCM.fetchFrom(GitSCM.java:810)
    at hudson.plugins.git.GitSCM.compareRemoteRevisionWithImpl(GitSCM.java:701)
    at hudson.plugins.git.GitSCM.compareRemoteRevisionWith(GitSCM.java:571)
    ... 14 more
Caused by: hudson.plugins.git.GitException: Command "git -c core.askpass=true fetch --tags --progress https://user@bitbucket.org/company/project.git +refs/heads/*:refs/remotes/origin/*" returned status code 143:
stdout: 
stderr: 
    at org.jenkinsci.plugins.gitclient.CliGitAPIImpl.launchCommandIn(CliGitAPIImpl.java:1719)
    at org.jenkinsci.plugins.gitclient.CliGitAPIImpl.launchCommandWithCredentials(CliGitAPIImpl.java:1463)
    at org.jenkinsci.plugins.gitclient.CliGitAPIImpl.access$300(CliGitAPIImpl.java:63)
    at org.jenkinsci.plugins.gitclient.CliGitAPIImpl$1.execute(CliGitAPIImpl.java:314)
    at hudson.plugins.git.GitSCM.fetchFrom(GitSCM.java:808)
    ... 16 more
Done. Took 45 Minuten
No changes

When I build the project manually I get the error that the username and password are wrong which is kind of inconsistent. 当我手动构建项目时,我得到用户名和密码错误的错误,这是不一致的。 Sometimes it fails with the error above and sometimes it fails saying that my username/password are wrong which I checked several times. 有时由于上面的错误而失败,有时却无法说明我多次检查了我的用户名/密码错误。

I tried to start the build manually with the "Trigger build remotely" check and it starts to build. 我尝试使用“远程触发构建”检查手动启动构建,然后开始构建。 The build still fails while trying to fetch from Bitbucket. 尝试从Bitbucket提取内容时,构建仍然失败。

I've searched around and found that many people already had this problem. 我四处搜寻,发现很多人已经遇到了这个问题。 However, the answers do not work for me. 但是,答案对我不起作用。

A couple of things - 有两件事-

  1. Please don't use Build Triggers/Poll SCM option. 请不要使用“构建触发器/轮询SCM”选项。 If you are polling the SCM/Bitbucket at a periodic interval, what's the point of configuring a webhook? 如果您要定期轮询SCM / Bitbucket,那么配置Webhook有什么意义?
  2. You may like to double-check the case of the letters you are using to configure the Jenkins/CI URL in Bitbucket. 您可能需要仔细检查用于在Bitbucket中配置Jenkins / CI URL的字母的大小写。 I had a similar problem and managed to resolve it after fixing the case. 我遇到了类似的问题,并在解决此问题后设法解决了该问题。 The URL had a few alphabets in uppercase, whereas the one I configured did not have it like that. 该URL有一些大写字母,而我配置的则没有这样的字母。 Remember the web-hook is case-sensitive. 请记住,网络挂钩区分大小写。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM