Monday, April 27, 2015

Jenkins: Zip files into email attachment and sent by notifier in Jenkins

Sometimes during CI testing using Jenkins, when the notifier sends an email to a recipient, the recipient may not be able to click the link in the notification email to go to view the content due to user privilege and authorization limit set on the user, but sometimes it is desirable for the user to view the output the the build details such as other files generated during the build even when user is not given the right to access the Jenkins server build detail page. In this case, the solution is to zip the content of the build and directly send as an attachment to the user. Below are some brief steps to do this (assuming we are working on the projet "HelloWorld"):

1. Install ArtifactDeployer plugin to jenkins
2. Install Email-ext to jenkins
3. Configure Email-ext in the "Configurate System" of "Manage Jenkins" and "Configure" of the project "HelloWorld"
4. Add "7za a -tzip deploy.zip "%WORKSPACE%\HelloWorld\HelloWorld\bin\Debug\*.*"" as a new "Execute Windows batch Command" in the build section of the project's "Configure"
5. Add "deploy.zip" in the files to archive as a new "Archive the artifact" post-build action in the project's "Configure"
6. Add "deploy.zip" in the attachment of the editable email notification as post-build action the project's "Configure"
7. Add send trigger for success in the editable email notification (in advanced)

If you set the smtp sever to something such as stmp.gmail.com, the email may be blocked, withe following messages in the build console output:

Error sending to the following VALID addresses: ---@----.com
SendFailedException message: 552-5.7.0 This message was blocked because its content presents a potential

This can be due to the zip attachment is not allow by that stmp settings.

No comments:

Post a Comment