How to configure a jenkins job to send mail if a S

2019-08-06 11:36发布

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 ?

2条回答
贪生不怕死
2楼-- · 2019-08-06 12:35

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

查看更多
淡お忘
3楼-- · 2019-08-06 12:35

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"
查看更多
登录 后发表回答