我使用了官方的人偶詹金斯模块。我添加了像这样的詹金斯工作。
jenkins::job { 'test-build-job':
config => template("${templates}/test-build-job.xml.erb"),
}
当我在人偶代理中运行此命令时
puppet agent -tv
我收到这样的错误:
错误:无法应用目录:验证Exec [reload-jenkins]失败:
'java -jar /usr/lib/jenkins/jenkins-cli.jar -s http://localhost:8080 重新加载配置”
不合格,没有指定路径。请限定命令或指定路径。 (文件:/etc/puppetlabs/code/environments/production/modules/jenkins/manifests/cli.pp,第42行)
我在cli.pp中遇到错误,我的cli.pp看起来像
class jenkins::cli {
if $caller_module_name != $module_name {
fail("Use of private class ${name} by ${caller_module_name}")
}
$jar = "${jenkins::libdir}/jenkins-cli.jar"
$extract_jar = "jar -xf ${jenkins::libdir}/jenkins.war WEB-INF/jenkins-cli.jar"
$move_jar = "mv WEB-INF/jenkins-cli.jar ${jar}"
$remove_dir = 'rm -rf WEB-INF'
exec { 'jenkins-cli' :
command => "${extract_jar} && ${move_jar} && ${remove_dir}",
path => ['/bin', '/usr/bin'],
cwd => '/tmp',
creates => $jar,
require => Service['jenkins'],
}
file { $jar:
ensure => file,
require => Exec['jenkins-cli'],
}
$port = jenkins_port()
# The jenkins cli command with required parameter(s)
$cmd = "java -jar ${jar} -s http://localhost:${port}"
# Reload all Jenkins config from disk (only when notified)
exec { 'reload-jenkins':
command => "${cmd} reload-configuration",
tries => 10,
try_sleep => 2,
refreshonly => true,
require => File[$jar],
}
# Do a safe restart of Jenkins (only when notified)
exec { 'safe-restart-jenkins':
command => "${cmd} safe-restart && /bin/sleep 10",
tries => 10,
try_sleep => 2,
refreshonly => true,
require => File[$jar],
}
}