上のリモートのために私は(何が起こっているかについてコメントを参照してください)次のコードを持っている:JGitはgitのを設定します:URIではなくHTTPSを:CircleCI
// Clone repository from GitHub into a local directory.
Git git = Git.cloneRepository()
.setBranch("gh-pages")
.setURI("https://github.com/RAnders00/KayonDoc.git")
.setDirectory(new File("/home/ubuntu/KayonDoc"))
.call();
// Print out remotes in config from JGit
Config config = git.getRepository().getConfig();
config.getSubsections("remote").forEach(it -> {
System.out.println(config.getString("remote", it, "url"));
});
// Prints https://github.com/RAnders00/KayonDoc.git
// Everything seems OK
// You could perform some changes to the repository here...
// Push changes to origin
git.push()
.setCredentialsManager(new UsernamePasswordCredentialsProvider("RAnders00", "hunter2"))
.call();
// Throws exception (look below)
Caught: org.eclipse.jgit.api.errors.TransportException: [email protected]:RAnders00/KayonDoc.git: push not permitted
org.eclipse.jgit.api.errors.TransportException: [email protected]:RAnders00/KayonDoc.git: push not permitted
at org.eclipse.jgit.api.PushCommand.call(PushCommand.java:164)
at org.eclipse.jgit.api.PushCommand.call(PushCommand.java:80)
at <your class> (YourClass.java:?)
Caused by: org.eclipse.jgit.errors.TransportException: [email protected]:RAnders00/KayonDoc.git: push not permitted
at org.eclipse.jgit.transport.BasePackPushConnection.noRepository(BasePackPushConnection.java:176)
at org.eclipse.jgit.transport.BasePackConnection.readAdvertisedRefsImpl(BasePackConnection.java:200)
at org.eclipse.jgit.transport.BasePackConnection.readAdvertisedRefs(BasePackConnection.java:178)
at org.eclipse.jgit.transport.TransportGitSsh$SshPushConnection.<init>(TransportGitSsh.java:341)
at org.eclipse.jgit.transport.TransportGitSsh.openPush(TransportGitSsh.java:166)
at org.eclipse.jgit.transport.PushProcess.execute(PushProcess.java:154)
at org.eclipse.jgit.transport.Transport.push(Transport.java:1200)
at org.eclipse.jgit.api.PushCommand.call(PushCommand.java:157)
... 3 more
JGitは.git/FETCH_HEAD
にgit:
URLを保存していますこれはプッシュに使用されます。git:
プロトコルは認証をサポートしていないため、リモートにプッシュすることができず、プロセスは失敗します。
.git/config
ファイルには、リモートの正しいhttps:
URIが含まれています(コードがhttps:
のURIを印刷しているのはそのためです)。
私の質問は:
私はJGitがhttps:
URI(その後、私は再びプッシュすることが可能になる)を正しく
を設定するために何ができますか?
この問題は、のみ(CircleCI、Ubuntuの12.04.2 LTS仮想ボックスに)非常に特殊な環境で発生する
- それは、15.10に14.04 LTSと12.04.2 LTS新鮮なUbuntuの分布を再現可能ではないとの再現可能ではないですWindows。
問題を再現する最も簡単な方法は、createにダミーのGitHubリポジトリを作成し、start building CircleCI上にダミープロジェクトを作成し、最初のビルドをSSHで再実行することです。 Groovy/JavaファイルをボックスにアップロードするSSH時間は30分です。 30分後、ボックスは強制的にシャットダウンされます。
私はこれが中にクローニングしたディレクトリにgit remote -v
を使用している場合は、私が取得する:あなたが定義されているように見えます(これgit:
のURIが実際に使用されているという事実に私を指す)
origin [email protected]:RAnders00/KayonDoc.git (fetch)
origin [email protected]:RAnders00/KayonDoc.git (push)
WindowsではhttpsのURLがそのまま残っていることを確認できます。 Linuxでこれが当てはまらない場合は、バグのように思えますが、私は[bugzillaをファイルします](https://eclipse.org/jgit/support/)です。 –
はい、コードを簡単に見ても明らかな理由はありませんでした。設定は、設定したURLから構成されています。たぶんあなたのコードでAPIのいくつかの不正な使用法を排除するためにあなたのマシン上でJGitに迅速なデバッグを行うことができます... – centic
私はあなただったら、私はちょうどsshのキーでgitプロトコルを使用したい – AdamSkywalker