8

I'm having trouble authenticating with BitBucket through HTTPS via the Maven JGitFlow plugin, run through git-bash on Windows.

The error message is: "Authentication is required but no CredentialsProvider has been registered". The suggestions I've seen though seem to assume that I have access to the JGit code itself as a developer.

I've had no trouble executing git commands directly (I'm using git-credential-winstore). Also, when I've supplied my username and password in the POM explicitly in the pom.xml file, it also worked.

However, I would not like my password to be uploaded to my BitBucket repository, and am looking for a way for the JGitFlow plugin to authenticate the same way as GIT itself does.

What am I doing wrong, and how can I fix that?

рüффп
  • 5,172
  • 34
  • 67
  • 113
Yiftach
  • 347
  • 1
  • 2
  • 12
  • Have you considered to switch from the HTTPS to SSH authentication? There is a simple instruction how to do it: https://confluence.atlassian.com/bitbucket/set-up-an-ssh-key-728138079.html#SetupanSSHkey-ssh1 – Ilya Serbis Jul 05 '18 at 22:21
  • And some links for those who use SourceTree on how to switch it to SSH authentication based on OpenSSH (which is the default for Git on Windows): https://learn.microsoft.com/en-us/vsts/git/use-ssh-keys-to-authenticate?view=vsts#how-can-i-start-using-ssh-in-a-repository-where-i-am-currently-using-https https://stackoverflow.com/a/47930338/355438 – Ilya Serbis Jul 05 '18 at 22:29
  • I recently found a project on github which supersedes on the idea (Not sure if it is a straight continuation), but it works with https authentication: https://github.com/aleksandr-m/gitflow-maven-plugin – Niels Bech Nielsen Nov 15 '18 at 08:39

1 Answers1

9

The following JGitFlow Maven plugin configuration works

<plugin>
    <groupId>external.atlassian.jgitflow</groupId>
    <artifactId>jgitflow-maven-plugin</artifactId>
    <version>1.0-m5.1</version>
    <configuration>
        <username>${git.user}</username>
        <password>${git.password}</password>
    </configuration>
</plugin>

Call it from the command line with the username and password as Java System Properties, i.e. with -Dgit.user=<user> and -Dgit.password=<password>, e.g.

mvn -Dgit.user=user@bitbucket.com -Dgit.password=secret jgitflow:release-start

Note: the plugin should really be updated with a Maven CredentialsProvider that is capable of obtaining the credentials from settings.xml and/or a Git credentials parser that uses the same mechanism as git on the command line.

Christoffer Soop
  • 1,458
  • 1
  • 12
  • 24
  • This is a clever solution I did not think about. However, would that make everyone who wants to work on my project have to do it as well (even if they use another form of credentials)? – Yiftach Aug 12 '16 at 19:35
  • Yes, each time they use the release plugin they would need to provide credentials. It _may_ be that they are only needed when you connect to the remote repository, I have not tested. Our use case is bungled as we also need to pass the credentials to a proxy... – Christoffer Soop Aug 16 '16 at 09:16
  • While that improves the situation (my credentials will not be shared with the people I collaborate with), that still forces my way of doing things (so it seems not well suited for public repositories, for example). – Yiftach Aug 18 '16 at 19:11