Skip to content
This repository was archived by the owner on Jun 2, 2019. It is now read-only.

Commit 305928b

Browse files
committed
Allow ssh privateKey in server settings
1 parent d116461 commit 305928b

File tree

5 files changed

+24
-3
lines changed

5 files changed

+24
-3
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -139,7 +139,7 @@ Examples
139139
# Create a settings.xml with the repo credentials
140140
maven::settings { 'maven-user-settings' :
141141
mirrors => [$central], # mirrors entry in settings.xml, uses id, url, mirrorof from the hash passed
142-
servers => [$central], # servers entry in settings.xml, uses id, username, password from the hash passed
142+
servers => [$central], # servers entry in settings.xml, uses id, username, password from the hash passed, privateKey
143143
proxies => [$proxy], # proxies entry in settings.xml, active, protocol, host, username, password, nonProxyHosts
144144
user => 'maven',
145145
}

spec/defines/complete-settings.xml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,11 @@
2222
<username>deploy_user</username>
2323
<password>deploy_pass</password>
2424
</server>
25+
<server>
26+
<id>maestro-deploy-ssh</id>
27+
<username>deploy_ssh_user</username>
28+
<privateKey>~/.ssh/id_rsa</privateKey>
29+
</server>
2530
</servers>
2631

2732
<profiles>

spec/defines/mirror-servers-settings.xml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,11 @@
2020
<username>deploy_user</username>
2121
<password>deploy_pass</password>
2222
</server>
23+
<server>
24+
<id>maestro-deploy-ssh</id>
25+
<username>deploy_ssh_user</username>
26+
<privateKey>~/.ssh/id_rsa</privateKey>
27+
</server>
2328
</servers>
2429

2530
</settings>

spec/defines/settings_spec.rb

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,11 @@ def read_file(filename)
3636
'username' => 'deploy_user',
3737
'password' => 'deploy_pass',
3838
}}
39+
let(:deploy_server_with_ssh) {{
40+
'id' => 'maestro-deploy-ssh',
41+
'username' => 'deploy_ssh_user',
42+
'privateKey' => '~/.ssh/id_rsa',
43+
}}
3944
let(:default_repo_config) {{
4045
'url' => url,
4146
'snapshots' => {
@@ -84,7 +89,7 @@ def read_file(filename)
8489
:user => "u",
8590
:home => "/home/u",
8691
:mirrors => [mirror],
87-
:servers => [mirror_server, deploy_server]
92+
:servers => [mirror_server, deploy_server, deploy_server_with_ssh]
8893
}}
8994

9095
it_behaves_like :maven_settings, "mirror-servers-settings.xml"
@@ -147,7 +152,7 @@ def read_file(filename)
147152
:user => "u",
148153
:home => "/home/u",
149154
:mirrors => [mirror],
150-
:servers => [mirror_server, deploy_server],
155+
:servers => [mirror_server, deploy_server, deploy_server_with_ssh],
151156
:default_repo_config => default_repo_config,
152157
:properties => properties,
153158
:local_repo => "/var/cache/maven/repository",

templates/settings.xml.erb

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,14 @@
2222
<% @servers.each do |server| -%>
2323
<server>
2424
<id><%= server['id'] %></id>
25+
<% ['username', 'password','privateKey' ] -%>
2526
<username><%= server['username'] %></username>
27+
<% unless server['password'].nil? -%>
2628
<password><%= server['password'] %></password>
29+
<% end -%>
30+
<% unless server['privateKey'].nil? -%>
31+
<privateKey><%= server['privateKey'] %></privateKey>
32+
<% end -%>
2733
</server>
2834
<% end -%>
2935
</servers>

0 commit comments

Comments
 (0)