Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Escape job names for shell commands #261

Merged
merged 1 commit into from
Apr 25, 2015
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions manifests/job/absent.pp
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,9 @@
# Delete the job
exec { "jenkins delete-job ${jobname}":
path => ['/usr/bin', '/usr/sbin', '/bin'],
command => "${jenkins::cli::cmd} delete-job ${jobname}",
command => "${jenkins::cli::cmd} delete-job \"${jobname}\"",
logoutput => false,
onlyif => "test -f ${config_path}",
onlyif => "test -f \"${config_path}\"",
require => Exec['jenkins-cli'],
}

Expand Down
16 changes: 6 additions & 10 deletions manifests/job/present.pp
Original file line number Diff line number Diff line change
Expand Up @@ -58,10 +58,9 @@
}

# Use Jenkins CLI to create the job
$cat_config = "cat ${tmp_config_path}"
$create_job = "${jenkins_cli} create-job ${jobname}"
$cat_config = "cat \"${tmp_config_path}\""
$create_job = "${jenkins_cli} create-job \"${jobname}\""
exec { "jenkins create-job ${jobname}":
path => ['/usr/bin', '/usr/sbin', '/bin'],
command => "${cat_config} | ${create_job}",
creates => [$config_path, "${job_dir}/builds"],
require => File[$tmp_config_path],
Expand All @@ -70,7 +69,6 @@
# Use Jenkins CLI to update the job if it already exists
$update_job = "${jenkins_cli} update-job ${jobname}"
exec { "jenkins update-job ${jobname}":
path => ['/usr/bin', '/usr/sbin', '/bin'],
command => "${cat_config} | ${update_job}",
onlyif => "test -e ${config_path}",
unless => "diff -b -q ${config_path} ${tmp_config_path}",
Expand All @@ -81,19 +79,17 @@
# Enable or disable the job (if necessary)
if ($enabled == 1) {
exec { "jenkins enable-job ${jobname}":
path => ['/usr/bin', '/usr/sbin', '/bin'],
command => "${jenkins_cli} enable-job ${jobname}",
onlyif => "cat ${config_path} | grep '<disabled>true'",
command => "${jenkins_cli} enable-job \"${jobname}\"",
onlyif => "cat \"${config_path}\" | grep '<disabled>true'",
require => [
Exec["jenkins create-job ${jobname}"],
Exec["jenkins update-job ${jobname}"],
],
}
} else {
exec { "jenkins disable-job ${jobname}":
command => "${jenkins_cli} disable-job ${jobname}",
path => ['/usr/bin', '/usr/sbin', '/bin'],
onlyif => "cat ${config_path} | grep '<disabled>false'",
command => "${jenkins_cli} disable-job \"${jobname}\"",
onlyif => "cat \"${config_path}\" | grep '<disabled>false'",
require => [
Exec["jenkins create-job ${jobname}"],
Exec["jenkins update-job ${jobname}"],
Expand Down