2016-05-30 13 views
2

サーバがHTTPSを受け付けないため、SSHプロトコルを介してリモートでgitコマンドを実行しています。私はbashスクリプトを通してそれを実行しており、変数としてユーザー名とパスワードを渡すことができれば好きです。ユーザ名とパスワードを含むSSH gitコマンド

具体的には、私はリポジトリの移行をやっていると

git remote add origin ssh://${username}:${password}@server.com/repo.git 

を実行しているとき、私はジェンキンス仕事を通じてスクリプトを実行し、簡単にパスワードの入力を要求することはできませんよ午前の問題を抱えています。キーをリモートサーバーにコピーするための最善の選択肢はありますか?

答えて

1
  1. もう1つの方法は、資格情報バインディングプラグインを使用することです。このプラグインを使用すると、資格情報を環境変数にバインドして、さまざまなビルドステップから使用できます。

  2. あなたはいつもあなたがGitリポジトリの最新バージョンを使用している、あなたはGIT_SSH_COMMAND環境変数を使用することができると仮定すると、手動で

乾杯

+0

um、私はあなたが質問を再読することをお勧めします。 OPは明示的にhttpsは許可されていません。 – eis

+0

私の最初のオプションを削除しました。キャッチしてくれてありがとう –

3

をリモートボックスにログインし、Githubの資格情報を追加することができます:

GIT_SSH, GIT_SSH_COMMAND 

     If either of these environment variables is set then git fetch 
     and git push will use the specified command instead of ssh when 
     they need to connect to a remote system. The command will be 
     given exactly two or four arguments: the [email protected] (or just 
     host) from the URL and the shell command to execute on that 
     remote system, optionally preceded by -p (literally) and the port 
     from the URL when it specifies something other than the default 
     SSH port. 

     $GIT_SSH_COMMAND takes precedence over $GIT_SSH, and is 
     interpreted by the shell, which allows additional arguments to be 
     included. $GIT_SSH on the other hand must be just the path to a 
     program (which can be a wrapper shell script, if additional 
     arguments are needed). 

     Usually it is easier to configure any desired options through 
     your personal .ssh/config file. Please consult your ssh 
     documentation for further details. 

あなたはgitを呼び出す前に、そう、あなたは、単に行うことができます

export GIT_SSH_COMMAND='ssh -i /path/to/key' 

あなたはSSHキーを使用することができない場合は、Jenkins Credential Binding pluginを使用することができます。

+0

GIT_SSH_COMMANDとの資格情報バインディングはどのように機能しますか?または、Jenkins Credentailのgitコマンドをssh鍵でバインドするだけでもかまいませんか? – red888

関連する問題