Cannot clone nor push with http://username@bitbucket:7990/scm
Symptoms
While running Bitbucket Server connected to JIRA User Directory, it is not possible to clone nor push in the following combination:
git clone http://username@bitbucket:7990/scm/ACME/acmerepo.git
Diagnosis
To simulate the request that Bitbucket Server is making to JIRA and see what JIRA is returning:
Create a file named "post-data" with the following contents:
<?xml version="1.0" encoding="UTF-8" standalone="yes"?> <password> <value></value> </password>
Run the following cURL command (from the directory where the file was created) with
<application-name>
and<application-password>
replaced with the application name and application password that Bitbucket Server is using to connect to JIRA as a user directory:curl -v -X POST -H "Accept: application/xml" -H "Content-Type: application/xml" -u <application-name>:<application-password> https://www.acme.com/jira/rest/usermanagement/1/authentication?username=bbunny --data @post-data
If JIRA is integrated with IIS, the response should contain something like:
Server: Microsoft-IIS/7.5 ... X-Powered-By: ASP.NET
Cause
JIRA uses a 400 response code with a specific message in the body to indicate to Bitbucket Server that authentication for a particular user has failed. In this case the response body and content-type are being mangled by IIS behavior.
This causes Bitbucket Server to mis-parse the response from JIRA and fall over with a 500 error on the client.
Resolution
Edit the
web.config system.webServer
section and sethttpErrors existingResponse
attribute to "PassThrough":<system.webServer> ... <httpErrors existingResponse="PassThrough"></httpErrors> ... </system.webServer>
For more information check Integrating JIRA with IIS.