From dcc7612c6b653fd9301612febd62d77700ffe8c2 Mon Sep 17 00:00:00 2001 From: Elyse Salberg Date: Thu, 2 Aug 2018 17:04:11 -0400 Subject: [PATCH] Allow custom location for slave JAVA command --- manifests/slave.pp | 5 ++++- spec/classes/jenkins_slave_spec.rb | 7 +++++++ templates/jenkins-slave-defaults.erb | 2 +- 3 files changed, 12 insertions(+), 2 deletions(-) diff --git a/manifests/slave.pp b/manifests/slave.pp index fd2a1f16f..882ff7116 100644 --- a/manifests/slave.pp +++ b/manifests/slave.pp @@ -87,7 +87,6 @@ # can be a String, or an Array. # # [*proxy_server*] -# # Serves the same function as `::jenkins::proxy_server` but is an independent # parameter so the `::jenkins` class does not need to be the catalog for # slave only nodes. @@ -95,6 +94,9 @@ # [*swarm_client_args*] # Swarm client arguments to add to slave command line. More info: https://github.com/jenkinsci/swarm-plugin/blob/master/client/src/main/java/hudson/plugins/swarm/Options.java # +# [*java_cmd*] +# Path to the java command in ${defaults_location}/jenkins-slave. Defaults to '/usr/bin/java' +# # === Examples # @@ -140,6 +142,7 @@ Any $java_args = undef, Any $swarm_client_args = undef, Boolean $delete_existing_clients = false, + Any $java_cmd = '/usr/bin/java', ) inherits jenkins::params { if versioncmp($version, '3.0') < 0 { diff --git a/spec/classes/jenkins_slave_spec.rb b/spec/classes/jenkins_slave_spec.rb index 9828a7b1d..4c75533f6 100644 --- a/spec/classes/jenkins_slave_spec.rb +++ b/spec/classes/jenkins_slave_spec.rb @@ -253,6 +253,13 @@ end end end # delete_existing_clients + + describe 'with a non-default $java_cmd' do + let(:params) { { java_cmd: '/usr/local/bin/java' } } + + it { is_expected.to contain_file(slave_runtime_file).with_content(%r{^JAVA="#{java_cmd}"$}) } + end + end shared_examples 'using slave_name' do diff --git a/templates/jenkins-slave-defaults.erb b/templates/jenkins-slave-defaults.erb index e13d5bfe5..5b629557a 100644 --- a/templates/jenkins-slave-defaults.erb +++ b/templates/jenkins-slave-defaults.erb @@ -4,7 +4,7 @@ # this file can not be used in its current state as a systemd EnvironmentFile. # location of java -JAVA=/usr/bin/java +JAVA=<%= @java_cmd %> # arguments to pass to java #JAVA_ARGS="-Xmx256m"