简体   繁体   中英

Bitbucket Hook fails for Jenkins Project

I'm trying to build a Jenkins Project from a Bitbucket Repository. Those builds should be executed on every push. Jenkins is set up on my local computer.

I've set up port forwarding so Jenkins can be used from my external IP address.

I've install the Bitbucket Plugin for Jenkins: https://wiki.jenkins-ci.org/display/JENKINS/BitBucket+Plugin

I configured my project with the following settings: 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.

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).

The Bitbucket Push Log shows following exception:

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.

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. If you are polling the SCM/Bitbucket at a periodic interval, what's the point of configuring a webhook?
  2. You may like to double-check the case of the letters you are using to configure the Jenkins/CI URL in Bitbucket. 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. Remember the web-hook is case-sensitive.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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