Reputation: 1973
I need to pass the value to Ansible playbook yml from Jenkins
Could you please help me ?
Upvotes: 4
Views: 17820
Reputation: 23811
Ansible-Playbook plugin didn't give you the full power off Ansible with jenkins, I can share the method that how I am using ansible with jenkins which will give you exactly the same power as you are using it from the command line.
Let's say, you job name is "stackoverflow
" then you can put the ansible-scripts
directory inside the /var/lib/jenkins/jobs/stackoverflow/workspace
and use it in your jenkins job like this:
After that you can use the power of shell environment:
Once you will configure this job then you can use it as you are normally using the ansible from the command line:
Please adjust the settings as per your environment.
Hope this will help you or other who want to use ansible from the jenkins.
Upvotes: 8
Reputation: 138
Just because I was looking for this recently, in addition to the answer above, on any ansible build step, you can click on advanced, and then extra variables and add a variable there. If you have a choice step that stores the value of the choice in a variable, you can reference that choice variable in a later extra variable by using ${choice_variable}.
Upvotes: 5