从Jenkins调用Ansible Playbook的路径配置问题咨询
Hey there! Let’s break down exactly what path you need to enter in the Invoke Ansible Playbook step of your Jenkins task.
First, let’s recap the structure of your repo: the playbook lives at provision/playbook.yml inside the soccer-stats repository. Once Jenkins pulls your Git repo into its workspace, the path you use depends on how you’ve configured the Git checkout step.
Case 1: Default Git Checkout (Repo in Jenkins Workspace Root)
If you didn’t set a custom "Local directory" in your Jenkins task’s Git configuration, the repo files will be pulled directly into the root of your Jenkins job’s workspace. In this case, the path you need to enter is:
provision/playbook.yml
Case 2: Custom Local Directory for Git Checkout
If you specified a subfolder (for example, you entered soccer-stats in the "Local directory" field under Git settings), you’ll need to prepend that folder name to the path:
soccer-stats/provision/playbook.yml
Quick Way to Verify the Path
If you’re unsure about the exact structure in your Jenkins workspace, add a temporary "Execute shell" step before the Ansible playbook invocation. Run this command:
find . -name playbook.yml
This will print the full relative path to the playbook from your workspace root—just copy that path into the Ansible playbook field and you’re good to go!
内容的提问来源于stack exchange,提问作者Nttrungit90

