git-plugin で remote repo から clone するとき ssh passphrase は空でなければいけない
現象
[root@localhost jenkins]# su - jenkins -bash-4.1$ ssh-keygen Generating public/private rsa key pair. Enter file in which to save the key (/var/lib/jenkins/.ssh/id_rsa): Enter passphrase (empty for no passphrase): XXXXXX Enter same passphrase again: XXXXXX Your identification has been saved in /root/.ssh/id_rsa. Your public key has been saved in /root/.ssh/id_rsa.pub. The key fingerprint is: d5:71:f0:69:41:36:6f:f5:5f:a9:e8:1a:91:b1:69:6b root@localhost.localdomain The key's randomart image is: +--[ RSA 2048]----+ | oo* .| | . = =+| | .. . +.=| | .= ....o| | S* . . .| | . + | | E . | | . o | | . | +-----------------+
$ cat/var/lib/jenkins/.ssh/id_rsa.pub
した結果を github の SSH keys に貼っ付けるgit-plugin を入れた jenkins で ... リストにある各ジョブのリンク -> 「設定」 -> ソースコード管理 -> 「Git」をチェック -> Repository URL に
git@github.com:USER_NAME/REPO_NAME.git
を入れる次の stderr を画面上に表示する。jenkins ビルド上で git clone できない
Failed to connect to repository : Command "git ls-remote -h git@github.com:USER_NAME/REPO_NAME.git HEAD" returned status code 128: stdout: stderr: Permission denied (publickey). fatal: Could not read from remote repository. Please make sure you have the correct access rights and the repository exists.
なぜでしょう
- git-plugin を利用するとき passphrase は空でなければいけないから
- (git-plugin 製作者は、この仕様を直す予定はない)
対策
referred:
[JENKINS-20879] SSH Credentials (private key with passphrase) do not work - Jenkins JIRA