1

I want to send email with content from .yml file output.

I've created a Jenkins job using groovy script and inside groovy I'm using shell script to call .yml file and inside I'm checking the url's health check using Ansible's URI module.

Output on the Jenkins console of .yml file display with key words as "Item", "msg", "Status/Status/Code" and "url" and some values against "Item", "msg", "Status/Status/Code" and "url".

I want to read these output of the .yml file and send to email in HTML format. In HTML page header/column of the email will be like below:

URL                          Status_Code                            MSG
https://example.com           200,301                              Ok
https://example1.com          -1                                           
'Status code was not [200, 301]: Request failed: <urlopen error [Errno 111] Connection refused>', u'redirected'

NOTE: Here values against URL, Status_Code and MSG are being displayed on Jenkins console as .yml file's output.

Please guide and suggest as I'm new to Ansible.

Thanks & Regards Ram

Law29
  • 3,557
  • 1
  • 16
  • 28
Ram_Mady
  • 11
  • 2

1 Answers1

1

The native Ansible way would be to utilize the mail_module. The Jenkins way would be to use a plugin like Email ext plugin and generate the email out of the Jenkins output.

However using Ansible for the sake of the uri module is overkill. I suggest to call curl from groovy like here.

Henrik Pingel
  • 9,380
  • 2
  • 28
  • 39