在Jenkins控制台输出中获得以下错误,
[Pipeline] ansiblePlaybook [pipeline -job] $ ansible-playbook my_playbook.yml -i inventories/a/hosts FATAL: command execution failed java.io.IOException: Process working directory '/var/lib/jenkins/workspace/pipeline -job' doesn't exist! at hudson.Proc$LocalProc.(Proc.java:248) at hudson.Proc$LocalProc.(Proc.java:219) at hudson.Launcher$LocalLauncher.launch(Launcher.java:937) at hudson.Launcher$ProcStarter.start(Launcher.java:455)
我的詹金斯管道是
pipeline {
agent any
stages {
stage('Build') {
steps {
ansiblePlaybook( credentialsId: 'private_key', inventory: 'inventories/a/hosts', playbook: 'my_playbook.yml')
}
}
}
}
答案 0 :(得分:0)
我必须在命令中添加安装:“ ansible”,其中“ ansible”是Jenkins Global Tool Configuration中Ansible安装的名称(必须提供“ Ansible可执行文件目录的路径”)。 / p>
另外,ansible剧本也必须位于工作区文件夹中。请参阅此帖子以复制到工作区文件夹how to copy files from a directory outside the workspace to workspace in Jenkins pipeline(这需要文件操作jenkins插件才能起作用。https://plugins.jenkins.io/file-operations/)
ansiblePlaybook (
playbook: "first.ansible",
colorized: true,
installation: "ansible"
)