Bamboo fails the connection to a Git Repository even 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 the connection to a Git Repository even when the server and the application 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
The issue is also present on regular Git fetch/clone commands on both Bamboo server and Agents reporting connection timeout errors.
Cause
Bamboo relies on the external Git program (capability) to connect to an HTTP-based Git repository during the repository creation process, ensuring that the repository is accessible in a production environment. That's also true when the Bamboo application runs Git commands that would connect to repositories hosted using HTTP. While Bamboo can manage HTTP proxy settings through Java properties, the external git
program itself requires a separated, external configuration for an outbound HTTP proxy to function correctly. If this configuration is missing, Git will attempt to connect to the repository directly, which may result in failure due to existing network restrictions.
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 and Agents to the Git repository URLs. Keep in mind that IP addresses associated with the Git repository URLs 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
The steps below apply to all Bamboo components that make use of Git. You will need to replicate the Git proxy setup on every Bamboo Agent that requires external Git access. Additionally, be sure to repeat the same steps on the Bamboo server if required.
To know how to configure an HTTP Proxy for general application traffic (not Git) please check the following KB articles:
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