From 916b053dca5436ebd147111c466be06b9e3f9f84 Mon Sep 17 00:00:00 2001 From: awlx Date: Thu, 25 Feb 2016 13:50:39 +0100 Subject: Added support for SSH Key usage and ssh-agent-forwarding --- lib/oxidized/hook/githubrepo.rb | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/lib/oxidized/hook/githubrepo.rb b/lib/oxidized/hook/githubrepo.rb index 7fc6677..b959f6d 100644 --- a/lib/oxidized/hook/githubrepo.rb +++ b/lib/oxidized/hook/githubrepo.rb @@ -49,8 +49,13 @@ class GithubRepo < Oxidized::Hook log "Using https auth", :debug Rugged::Credentials::UserPassword.new(username: cfg.username, password: cfg.password) else - log "Using ssh auth", :debug - Rugged::Credentials::SshKeyFromAgent.new(username: 'git') + @credentials ||= if cfg.has_key?('pubkey') && cfg.has_key?('privkey') + log "Using ssh auth with key", :debug + Rugged::Credentials::SshKey.new(username: 'git', publickey: File.expand_path(cfg.pubkey), privatekey: File.expand_path(cfg.privkey)) + else + log "Using ssh auth with agentforwarding", :debug + Rugged::Credentials::SshKeyFromAgent.new(username: 'git') + end end end -- cgit v1.2.1 From a2b6dd71dbc4c57423b0f6b332bf035cd097c3dd Mon Sep 17 00:00:00 2001 From: awlx Date: Thu, 25 Feb 2016 13:52:54 +0100 Subject: Added documenation hint --- README.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/README.md b/README.md index 370d07b..844347d 100644 --- a/README.md +++ b/README.md @@ -595,6 +595,8 @@ This hook configures the repository `remote` and _push_ the code when the specif * `remote_repo`: the remote repository to be pushed to. * `username`: username for repository auth. * `password`: password for repository auth. + * `pubkey`: publickey for repository auth. + * `privkey`: privatekey for repository auth. When using groups repositories, each group must have its own `remote` in the `remote_repo` config. -- cgit v1.2.1 From a4bdbb84b2ecc7dc3499c169a803b90fdb650f98 Mon Sep 17 00:00:00 2001 From: awlx Date: Thu, 25 Feb 2016 14:14:00 +0100 Subject: Removed unnecessary repetition --- lib/oxidized/hook/githubrepo.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/oxidized/hook/githubrepo.rb b/lib/oxidized/hook/githubrepo.rb index b959f6d..a6c6807 100644 --- a/lib/oxidized/hook/githubrepo.rb +++ b/lib/oxidized/hook/githubrepo.rb @@ -49,7 +49,7 @@ class GithubRepo < Oxidized::Hook log "Using https auth", :debug Rugged::Credentials::UserPassword.new(username: cfg.username, password: cfg.password) else - @credentials ||= if cfg.has_key?('pubkey') && cfg.has_key?('privkey') + if cfg.has_key?('pubkey') && cfg.has_key?('privkey') log "Using ssh auth with key", :debug Rugged::Credentials::SshKey.new(username: 'git', publickey: File.expand_path(cfg.pubkey), privatekey: File.expand_path(cfg.privkey)) else -- cgit v1.2.1