Karthick
Karthick

Reputation: 1973

How to pass the value to Ansible playbook from Jenkins

I need to pass the value to Ansible playbook yml from Jenkins

Could you please help me ?

enter image description here

Upvotes: 4

Views: 17820

Answers (2)

Arbab Nazar
Arbab Nazar

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:

enter image description here After that you can use the power of shell environment: enter image description here Once you will configure this job then you can use it as you are normally using the ansible from the command line: enter image description here

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

MLindsay
MLindsay

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

Related Questions