1

Jenkins CI を homebrew からインストールしました ( brew install jenkins)。したがって、それは自分のユーザーの下で実行されます。Git リポジトリへの SSH アクセスを除いて、すべて正常に動作します。Jenkins を実行するための別のユーザー (jenkins など) を作成して、別の SSH キーを作成したくありません。自分の SSH キーを使いたいだけです。コマンドラインでのリモート git リポジトリへのアクセスは、ssh キーで正常に機能しますが、Jenkins では機能しません。「許可が拒否されました(公開鍵)」エラーが発生します(ユーザー名とプロジェクトは難読化されています(<user>および<project>)):

Started by user anonymous
Checkout:workspace / /Users/<user>/.jenkins/jobs/<project>_run_tests/workspace - hudson.remoting.LocalChannel@456d3d51
Using strategy: Default
Last Built Revision: Revision 093f1641f26632afd1a74c14276ec544356c1d08 (origin/dev)
Checkout:workspace / /Users/<user>/.jenkins/jobs/<project>_run_tests/workspace - hudson.remoting.LocalChannel@456d3d51
Fetching changes from 1 remote Git repository
Fetching upstream changes from ssh://git@bitbucket.org/<user>/<project>.git
ERROR: Problem fetching from origin / origin - could be unavailable. Continuing anyway
ERROR:  (Underlying report) : Error performing command: /usr/local/bin/git fetch -t ssh://git@bitbucket.org/<user>/<project>.git +refs/heads/*:refs/remotes/origin/*
Command "/usr/local/bin/git fetch -t ssh://git@bitbucket.org/<user>/<project>.git +refs/heads/*:refs/remotes/origin/*" returned status code 128: Permission denied (publickey).
fatal: The remote end hung up unexpectedly

ERROR: Could not fetch from any repository
FATAL: Could not fetch from any repository
hudson.plugins.git.GitException: Could not fetch from any repository
    at hudson.plugins.git.GitSCM$2.invoke(GitSCM.java:1012)
    at hudson.plugins.git.GitSCM$2.invoke(GitSCM.java:972)
    at hudson.FilePath.act(FilePath.java:783)
    at hudson.FilePath.act(FilePath.java:765)
    at hudson.plugins.git.GitSCM.checkout(GitSCM.java:972)
    at hudson.model.AbstractProject.checkout(AbstractProject.java:1195)
    at hudson.model.AbstractBuild$AbstractRunner.checkout(AbstractBuild.java:568)
    at hudson.model.AbstractBuild$AbstractRunner.run(AbstractBuild.java:457)
    at hudson.model.Run.run(Run.java:1404)
    at hudson.model.FreeStyleBuild.run(FreeStyleBuild.java:46)
    at hudson.model.ResourceController.execute(ResourceController.java:88)
    at hudson.model.Executor.run(Executor.java:230)

私のsshキーを使用してgitサーバーに接続していないようです。jenkins launchagent plist に UserName キーを追加しようとしましたが、再起動しましたが、効果はありませんでした。

ジェンキンに SSH キーを使用させてリモート git リポジトリに接続させるにはどうすればよいですか?

4

1 に答える 1

2

homebrewがJenkinsをどのように設定するかはわかりませんが、sshエージェントにアクセスできず、sshキーがパスフレーズで保護されているコンテキストで実行されているようです。

ターミナルウィンドウで実行すると、sshクライアントが認証に使用するSSH_AUTH_SOCK変数が環境にあります。sshエージェントを使用できない場合は、sshキーからパスフレーズを削除する必要があります。

于 2012-03-22T22:54:00.950 に答える