Bamboo fails testing the connection to a Git Repository when configured to use an outbound HTTP Proxy server
Platform Notice: Data Center - This article applies to Atlassian products on the Data Center platform.
Note that this knowledge base article was created for the Data Center version of the product. Data Center knowledge base articles for non-Data Center-specific features may also work for Server versions of the product, however they have not been tested. Support for Server* products ended on February 15th 2024. If you are running a Server product, you can visit the Atlassian Server end of support announcement to review your migration options.
*Except Fisheye and Crucible
Summary
Bamboo fails to test the connection to a Git Repository when the server is configured to use an outbound HTTP Proxy server
Environment
- Bamboo Data Center
- HTTP Proxy
- GitHub, Bitbucket Cloud, and/or any HTTP-based Git repository
Diagnosis
When setting up a Bitbucket Cloud, GitHub Repository or any HTTP-based Git repository in a Bamboo server configured with an outbound HTTP Proxy, the "Test Connection" button fails with the following error:
fatal: unable to access 'https://<Git_URL>/myproject/test.git/': Failed to connect to github.com port 443: Connection timed out
Cause
Bamboo relies on the external Git capability to connect to an HTTP-based Git repository during the repository creation process, ensuring the repository is accessible in a production environment. While Bamboo can handle HTTP proxy settings through Java properties, the git
binary itself requires a separate configuration for an outbound HTTP proxy to work. If this configuration is missing, Git will attempt to connect to the repository directly and potentially fail due to existing network policies.
Solution
1 - Allow firewall rules to pass the traffic directly
Engage with your Network or Security teams to allow a direct connection from the Bamboo server to the Git repository URL. Keep in mind that IP addresses associated with the Git repository URL may change without notice, which may require updating the firewall with dynamic or DNS-based rules.
2 - Configure Git to use an HTTP Proxy
The recommended approach is to setup the git
program to use an outbound HTTP proxy for accessing the Git repository URL
Option A: Configure the HTTP Proxy using a ~/.gitconfig
file
As the same user that runs the Bamboo service, run the commands below, replacing the Proxy hostname and port accordingly:
GitHub
$ git config --global http.https://github.com.proxy http://proxy.mydomain.net:8080
Bitbucket Cloud
$ git config --global http.https://bitbucket.org.proxy http://proxy.mydomain.net:8080
Generic Git
$ git config --global http.https://mygitserver.com.proxy http://proxy.mydomain.net:8080
These commands will create or append to the users' ~/.gitconfig
file:
[http "https://github.com"]
proxy = http://proxy.mydomain.net:8080
[http "https://bitbucket.org"]
proxy = http://proxy.mydomain.net:8080
[http "https://mygitserver.com"]
proxy = http://proxy.mydomain.net:8080
Note: Further adjustments may be required on the ~/.gitconfig
file to satisfy specific customer requirements. We recommend you check the git-config documentation for additional instructions.
Option B: Configure the HTTP Proxy using environment variables
Setting environment variables is a broad method that does not permit specifying particular Git repository URLs for proxy usage. Consequently, all requests from the git
program, as well as potentially other applications utilizing the same proxy environment variables, will be routed through the designated proxy host, unless they are excluded by the no_proxy
environment variable.
Declare the following environment variables in your user profile. Replace the Proxy hostname and port accordingly:
Linux
export http_proxy=http://proxy.mydomain.net:8080
export https_proxy=https://proxy.mydomain.net:8443
export no_proxy="localhost,127.0.0.1,localaddress,mydomain.net"
Windows
set http_proxy http://proxy.mydomain.net:8080
set https_proxy https://proxy.mydomain.net:8443
set no_proxy localhost,127.0.0.1,localaddress,mydomain.net