How to configure a jenkins job to send mail if a SCM commit

烂漫一生 提交于 2019-12-11 11:56:26

问题


I have problems with configuring a jenkins job that need to do the following task :

  • scheduled every 30 minutes => OK
  • do an update (CVS, SVN, ...) => OK
  • send an email if a change is detected in the SCM repo => KO

So my job is configured as follow :

  • Source Code Management : cvs root / branch / ...
  • Build Triggers : Poll SCM : */30 * * * *
  • Build : No buils step
  • Post-build Actions : E-mail Notification

But I received emails only when the build failed and not when an update is detected.

Any hint ?


回答1:


Short answer: add an email-ext trigger of type "Always" (or "Before Build" or from other triggers e.g. in list below).

jenkins email-ext plugin. https://wiki.jenkins-ci.org/display/JENKINS/Email-ext+plugin Read about Triggers '''By default, the only trigger configured is the "Failure" trigger. To add more triggers, select one from the dropdown, and it will be added to the list.'''

  1. In job configuration - Editable Email Notification - select Advanced box. Add an email Trigger. e.g. list of triggers:
Aborted
Always
Before Build
Failure -> Unstable (Test Failures)
Failure - Any
Failure - First
Failure - Second
Failure - Still
Fixed
Not Built
Script - After Build
Script - Before Build
Status Changed
Success
Test Improvement
Test Regression
Unstable (Test Failures) - First
Unstable (Test Failures) - Still
Unstable (Test Failures)
Unstable (Test Failures)/Failure -> Success
  1. You may also select and configure who gets the emails. Select "Before Build" trigger and choose "Sent To" list. Send To lists choice e.g.
Culprits 
Developers 
Recipient List 
Requestor 
Suspects build fail
Suspects tests fail
Upstream Committers

The email lists are configured in the general jenkins configuration.

This answer touches on the topic of this question: Send email to commiters from Jenkins email-ext on every build




回答2:


you can try it with a little script where:

  • you will check is any new commits in the repo
  • if changes present you have two ways:
    1. is to run sending email from command line
    2. create in jenkins some notification job, which will just send mails and run it with "java -jar jenkins-cli.jar -s yourserver build NotificationJobName"


来源:https://stackoverflow.com/questions/24930314/how-to-configure-a-jenkins-job-to-send-mail-if-a-scm-commit

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!