Skip to content

Commit

Permalink
Merge pull request #352 from kevinhankens/jenkins_cli_ssh_keyfile
Browse files Browse the repository at this point in the history
Adding cli_ssh_keyfile parameter to specify the location of a private key
  • Loading branch information
R. Tyler Croy committed Aug 8, 2015
2 parents c1ba76e + b586c68 commit 9c39706
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 1 deletion.
17 changes: 16 additions & 1 deletion manifests/cli.pp
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,23 @@

$port = jenkins_port()

# Provide the -i flag if specified by the user.
if $::jenkins::cli_ssh_keyfile {
$auth_arg = "-i ${::jenkins::cli_ssh_keyfile}"
} else {
$auth_arg = undef
}

# The jenkins cli command with required parameter(s)
$cmd = "java -jar ${jar} -s http://localhost:${port}"
$cmd = join(
delete_undef_values([
'java',
"-jar ${::jenkins::cli::jar}",
"-s http://localhost:${port}",
$auth_arg,
]),
' '
)

# Do a safe restart of Jenkins (only when notified)
exec { 'safe-restart-jenkins':
Expand Down
6 changes: 6 additions & 0 deletions manifests/init.pp
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,11 @@
# - CLI installation (both implicit and explicit) requires the unzip command
#
#
# cli_ssh_keyfile = undef (default)
# Provides the location of an ssh private key file to make authenticated
# connections to the Jenkins CLI.
#
#
# cli_tries = 10 (default)
# Retries until giving up talking to jenkins API
#
Expand Down Expand Up @@ -160,6 +165,7 @@
$proxy_port = undef,
$no_proxy_list = undef,
$cli = undef,
$cli_ssh_keyfile = undef,
$cli_tries = $jenkins::params::cli_tries,
$cli_try_sleep = $jenkins::params::cli_try_sleep,
$port = $jenkins::params::port,
Expand Down
2 changes: 2 additions & 0 deletions spec/classes/jenkins_cli_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,13 @@

context '$cli => true' do
let(:params) {{ :cli => true,
:cli_ssh_keyfile => '/path/to/key',
:config_hash => { 'HTTP_PORT' => { 'value' => '9000' } }
}}
it { should create_class('jenkins::cli') }
it { should contain_exec('jenkins-cli') }
it { should contain_exec('reload-jenkins').with_command(/http:\/\/localhost:9000/) }
it { should contain_exec('reload-jenkins').with_command(/-i\s\/path\/to\/key/) }
it { should contain_exec('safe-restart-jenkins') }
it { should contain_jenkins__sysconfig('HTTP_PORT').with_value('9000') }
end
Expand Down

0 comments on commit 9c39706

Please sign in to comment.