Bitbucket Hook fails for Jenkins Project
<p>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.</p>

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

<p>I've install the Bitbucket Plugin for Jenkins: <a href="https://wiki.jenkins-ci.org/display/JENKINS/BitBucket+Plugin" rel="nofollow">https://wiki.jenkins-ci.org/display/JENKINS/BitBucket+Plugin</a></p>

<p>I configured my project with the following settings:
SCM: Git:</p>

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

<p>Build Triggers:</p>

<pre><code>Build when a change is pushed to Bitbucket checked
Poll SCM: */1 * * * * 
</code></pre>

<p>Bitbucket: Went to the Project - Webhooks.</p>

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

<p>When I push to that Repository I can see that I'm getting a 200 Response (Successfull post to Jenkins).</p>

<p>The Bitbucket Push Log shows following exception:</p>

<pre><code>Polling SCM changes on master
Using strategy: Default
 &gt; git rev-parse --is-inside-work-tree # timeout=10
Fetching changes from the remote Git repositories
 &gt; 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
 &gt; git --version # timeout=10
using .gitcredentials to set credentials
 &gt; git config --local credential.username username # timeout=10
 &gt; git config --local credential.helper store --file=/Users/Shared/Jenkins/tmp/git7517617021208566630.credentials # timeout=10
 &gt; 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
 &gt; 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
</code></pre>

<p>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.</p>

<p>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.</p>

<p>I've searched around and found that many people already had this problem. However, the answers do not work for me.</p>