http://www.technicalpage.net/search/label/SQL

Jenkins: Create job, schedule job, send email notification



Configure Email-Jenkinds Notification:
Click Manage Jenkins
Click Configure Systems
Go to Email Notification section
Give the SMTP server name for example, for gmail: it is smtp.gmail.com
Check the box "Use SMTP Authentication"
Click Advanced - give username and password. username will be the email from which the email will be sent.
check "Use SSL". Make sure if you need to check this box or not depending upon your email.
Give the SMTP port
Give the email address at Reply-To Address
Give charset as UTF-8
Test the email configuration by checking - test config by sending test email. You give the receipent email address here.
click Apply and Save
Incase you get trouble getting email from jenkins , then open your email, go to my account, go to signing into google(for gmail), Turn on the Allow less secure app

Send Email:
Go to any jobs
Go to configure
Click Add post build action
Click Email Notification
add receipient email -- this will email to this address if email fails
Click Apply and Save
Now to run, click Build Now
To change the command, click the job and click configure
When the test case fails and you get email, you can click the link in the email which will take you to the jenkins site where you can click console output to see the log.
You can add plugins to send email notification in Json and XML format


Craete new job:
Click New item
Give name, check radio Freestyle project and click OK
Click drop down Add Build Step and click Execute Windows batch command
inside Build type below command:
java -version: This will give java version , simple code for the example purpose. This is cmd command or .bat command.

Schedule jobs:
Open the job
Click Configure
in Build Triggers section, click Build Periodically
For the scheduling commands(called cron pattern) , click help and get from there. There are examples also in the help.
Online resource: wikipedia has good explanation of the cron pattern.
To run at 7pm and 15 min: 15 19 * * *, 8 pm : H 20 * * *
after you write the cron pattern, click Apply and Save
And the execution starts.

No comments:

Post a Comment