I am using Gitlab as a repository in my RCP app. gitlab4j
is used to navigate groups and projects and jgit
is used to clone and fetch.
I set up tokens for accessing the Gitlab API and this works fine.
When I come to clone a repository (using jgit
), I get a popup which wants me to enter user and password for "GitLab". I can just press Cancel
and the clone action proceeds and completes successfully.
I have tried the same code outside of eclipse and I have no problem at this point.
I think that it has something to do with the eclipse proxy. How can I programmatically disable the proxy or configure it to ignore my Gitlab URL?
Git git = Git
.cloneRepository()
.setCredentialsProvider(new UsernamePasswordCredentialsProvider("PRIVATE-TOKEN", token))
.setDirectory(dir)
.setURI("https://my-gitlab-repo")
.setNoCheckout(true)
.setProgressMonitor(pm)
.call();
git.checkout()
.setCreateBranch(true)
.setName(DEFAULT_BRANCH)
.setStartPoint("refs/tags/" + tag.getName())
.call()
Further info
I have tried setting core.net
preferences in plugin_customization.ini
to define a proxy bybass but this does not help.
org.eclipse.core.net/nonProxiedHosts=git1.acme.com|localhost|127.0.0.1
org.eclipse.core.net/proxiesEnabled=true
org.eclipse.core.net/systemProxiesEnabled=false
I added the login credentials to the URL as well as setting the CredentialsProvider and this prevented the login popup.
Git git = Git
.cloneRepository()
.setCredentialsProvider(new UsernamePasswordCredentialsProvider("PRIVATE-TOKEN", token))
.setDirectory(dir)
.setURI("https://gitlab-user:{the-token-here}@my-gitlab-repo")
.setNoCheckout(true)
.setProgressMonitor(pm)
.call();