Send email notification from Jenkins

前端 未结 6 1762
悲哀的现实
悲哀的现实 2021-01-01 14:08

I want to send email notification when any job gets done. Please let me know how can we propagate.

6条回答
  •  慢半拍i
    慢半拍i (楼主)
    2021-01-01 14:58

    This answer is for sending mail using python script & outlook through Jenkins.

    You need to have PsExec.exe for this. This runs the applications remotely.

    create a freestyle project & in that run following dos shell command:

    path\to\psexec.exe -u username -p password -i 1 cmd -accepteula /c python path\to\SendMail.py

    Username & password is for the windows user account where outlook runs. path\to\SendMail.py is the location of the python script. SendMail.py kinda looks like this:

    import win32com.client as win32
    outlook=win32.Dispatch('outlook.application')
    mail=outlook.CreateItem(0)
    mail.To='abc@xyz.com'
    mail.Subject="Test Mail"
    mail.HTMLBody="Hiii, This is just a test mail."
    mail.Send()
    

    Here I'm using wind32com for executing outlook. The mail will be sent using the default account logged in outlook.

    You can trigger to build this project everytime after a job completes.

    Hope this is of any help to anyone :)

提交回复
热议问题