Get Ansible "PLAY RECAP" Failed value from Jenkins pipeline

294 views
Skip to first unread message

Manoranjan Panigrahi

unread,
Feb 5, 2019, 8:51:34 AM2/5/19
to Jenkins Users

Hello All,

 

I have Jenkins server setup on a windows 2016 server and Ansible Server installed on “RHEL 7” OS.

 

Through Jenkins pipeline I would like to get the value for “Failed=” parameter which is populated in “PLAY RECAP” section when a Ansible script is executed.

 

I am not able to achieve the same.

 

Could you please guide me.

Victor Martinez

unread,
Feb 5, 2019, 12:01:41 PM2/5/19
to Jenkins Users
Hi,

Not sure IIUC, you want to parse the console output to search for 'Failed='? How do you run the ansible script in the jenkins pipeline? 

Cheers

Richard Bywater

unread,
Feb 5, 2019, 5:08:59 PM2/5/19
to jenkins...@googlegroups.com
The Log Parser plugin might be useful for your use case although a disclaimer that I don't use it myself so can't vouch for it. 


Richard. 

--
You received this message because you are subscribed to the Google Groups "Jenkins Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to jenkinsci-use...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/jenkinsci-users/dc095196-4a13-4f11-a668-301e77bee560%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Manoranjan Panigrahi

unread,
Feb 5, 2019, 11:44:55 PM2/5/19
to Jenkins Users
Hi,
We are running ansible scripts in Jenkins pipeline over ssh.

Here is the code.

sshCommand remote: ansibleremote, command: "cd /home/rma/RSMP_Ansible_Scripts \n exec ansible-playbook FailJob.yml"

In case you have any approach to solve it, please suggest.

Regards,
Manoranjan

Victor Martinez

unread,
Feb 6, 2019, 4:33:57 AM2/6/19
to Jenkins Users
I use also ansible and I took the approach to convert the ansible playbook output to JUnit format and that helps me to see the number of executed tasks and their status (success, failed, skipped). 

In case you are interested about it:

Some snippets

ansible.cfg
[defaults]
callback_whitelist = junit

pipeline
try {
  sh "export JUNIT_OUTPUT_DIR=target ansible-playbook ..."
} catch (Exception e) {
  throw e
} finally {
  junit 'target/*'
}


You might need also the pip package pip install junit-xml

Not sure, if this particular suggestion might help to your use case.

Cheers
Reply all
Reply to author
Forward
0 new messages