Builds fail with "invalid privatekey" and "Git capability is not defined. Falling back to JGit"
Platform notice: Server and Data Center only. This article only applies to Atlassian products on the Server and Data Center platforms.
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
Builds fail during checkout, and the following two errors can be seen in the build logs:
Git capability is not defined. Falling back to JGit, which is no longer supported. Define native git capability to get rid of this error.
ssh://<bitbucket>:<port>/<project>/<repo.git>: invalid privatekey:
Environment
All supported versions of Bamboo.
Diagnosis
When reviewing the failed build logs, the following errors are present:
error 19-May-2023 10:58:38 Git capability is not defined. Falling back to JGit, which is no longer supported. Define native git capability to get rid of this error.
error 19-May-2023 10:58:38 Cannot fetch branch '<branch>' from 'ssh://<bitbucket>:<port>/<project>/<repository>.git' to source directory '<bamboo-agent-home>/xml-data/build-dir/_git-repositories-cache/<cache>'. ssh://<bitbucket>:<port>/<project>/<repository>.git: invalid privatekey: [B@5d42b0e
Cause
This happens when a native Git client is not installed in the remote agent (or in the Bamboo machine), which causes Bamboo to use its default JGit, which is known to have a few limitations.
Solution
Please make sure that a native Git client is installed on the agents and Bamboo machines, and that they are configured as capabilities:
Once Git has been installed:
- Agents: either restart them to pick up the Git path automatically or set it manually by going to Bamboo Administration > Agents > open the agent's page > Add capability > Git.
If you choose to restart the agent, you can check if the Git capability is now present under the Bamboo Administration > Agents > affected agent's page. - Bamboo: go to Bamboo Administration > Server capabilities > click Detect server capabilities.
If you still see the "invalid privatekey" error after the steps above, please make sure the SSH keys have been correctly created and configured as per the following articles: