Git Repo Troubleshooting

Hello all,

Are you using Bitbucket as a Source Repo and having issues with setting it up in Harness?

Issue: Insufficient Access/Permissions
As with almost any form of integration, the main problem that plagues us all is the required access or permissions rights. This is the same with all Git repo integrations as well. To start off the troubleshooting journey, please make sure that you have the proper access and permissions for Harness to connect with your Git repo. Typically, this will manifest itself in three general ways: Network, Password, SSH Keys

Solution 1
Network check time! First, get the Base URL and Port that your Git repo is available on. Then, SSH into the Harness delegate and check if that URL is accessible over the designated port (Hint: cURL and telnet are useful here).

Solution 2
Most (if not all) companies are leveraging some form of SSO or MFA to login to their different technologies and tools. If your company falls into this group, you’ll need to use an Access Token for Harness to talk to your Git Repo. This can be done by logging into your Git repo, setting up an Access Token (API Token), then supplying that token instead of a password inside of Harness.

Solution 3
If there is a desire to leverage an SSH key instead of an API token, you might find an issue with implementing an SSH key. Currently, there is an issue with leveraging OpenSSH based SSH keys in Harness. To fix this, you’ll need to run the following script ssh-keygen -t rsa -m PEM to generate an RSA based SSH key. Once this is done and the private key is added to the Git repo, you’ll either need to put the public key in the correct location on the delegate or copy the key text (including the BEGIN RSA and END RSA sections) into the Inline SSH box in Harness.

Issue: Webhook Not Posting to Harness
This one can be a little bit more difficult to diagnose because your webhook command will most likely still post a 200 response and seem good, but none of the committed code in your Git repo is sent up. There is one strange intermittent issue that I’ve seen and one more common but lesser known issue that we’ve seen.

Solution 1
In some cases (not all) there is an issue with the webhook sending code up to Harness. This has been an issue with an empty commit (again, intermittent, so it won’t apply to all). When you make your next change to the YAML and go to commit, make sure you add commit information (subject and description).

Solution 2
In the case of BitBucket, there are two distinct versions that exist. One is the cloud version that is hosted by Atlassian (known as BitBucket Cloud). The other is the on-premise version of BitBucket that enterprises will leverage when they don’t want data leaving their internal network (known as BitBucket Server). Both versions act the same in regards to their use of git and their UI, but they way they send information on the backend via a webhook is different. Currently, Harness has OOTB support for BitBucket Cloud without any extra configuration. With BitBucket Server, Harness requires a specific webhook plug-in to exist for the integration to be successul:

Harness is currently working on the BitBucket Server integration to avoid the extra plug-in requirement and I will change this post when that happens.

Let me know in the comments if anything else comes up with your Git repo integration troubleshooting and I’ll add it here!

Don’t forget to Comment/Like/Share!

1 Like

Make sure it’s that particular webhook for Bitbucket. There’s also Post-Receive Webhook, but that doesn’t send the Xdata which is used to determine that this is a Bitbucket request.

1 Like

Thanks Karl! Very helpful clarification for this situation!

1 Like