hudson--配置邮件

如果希望在构建完成后将构建结果以邮件的形式发送给相关的用户,推荐安装Hudson Email Extension Plugin插件,它比系统默认的邮件设置的功能要强大,可以设置邮件标题及内容的格式,也可以指定触发邮件的情况,该插件安装完成后可以在“系统设置”中看到如下配置项:

Extended E-mail Notification

 

Override Global Settings 如果勾选上,就会覆盖job中的邮件配置。

SMTP server:邮件服务器地址,可以不填,不填则使用javamail发送,如果在公司内部使用,可以使用内网邮箱。

Default user E-mail suffix:缺省的邮件后缀, 例如,如果这里设定了@acme.org ,那么用户foo的默认邮件地址为foo@acme.org

System Admin E-mail Address:就是发送邮件的用户,这个用户不要求一定存在。

其它配置项默认即可,这里注意一下,在Default Content中可以增加一下内容,比如构建日志$BUILD_LOG,具体的配置详见Content Token Reference后面的那个帮助Help for feature: Content Token Reference

 

保存后就配置好了。这样在建立job时,可以在job设置里指定邮件的收件人和触发邮件的情况。

 

具体如下,在job的设置中找到Post-build Actions,在其中找到Editable Email Notification,勾选上。

 

Global Recipient List:收件人列表,以英文逗号分隔。

其它配置项与系统设置中相同。

重点在“Advanced”

All arguments are optional. Arguments may be given for each token in the form name="value" for strings and in the form name=value for booleans and numbers. The {'s and }'s may be omitted if there are no arguments.

Examples: $TOKEN, ${TOKEN}, ${TOKEN, count=100}, ${ENV, var="PATH"}

Available Tokens
  • ${DEFAULT_SUBJECT} - This is the default email subject that is configured in Hudson's system configuration page.
  • ${DEFAULT_CONTENT} - This is the default email content that is configured in Hudson's system configuration page.
  • ${PROJECT_DEFAULT_SUBJECT} - This is the default email subject for this project. The result of using this token in the advanced configuration is what is in the Default Subject field above. WARNING: Do not use this token in the Default Subject or Content fields. Doing this has an undefined result.
  • ${PROJECT_DEFAULT_CONTENT} - This is the default email content for this project. The result of using this token in the advanced configuration is what is in the Default Content field above. WARNING: Do not use this token in the Default Subject or Content fields. Doing this has an undefined result.
  • ${BUILD_LOG, maxLines , escapeHtml } - Displays the end of the build log.
    • maxLines - display at most this many lines of the log.
      Defaults to 250.
    • escapeHtml - If true, HTML is escaped.
      Defaults to false.
  • ${BUILD_LOG_REGEX, regex , linesBefore , linesAfter , maxMatches , showTruncatedLines , substText } - Displays lines from the build log that match the regular expression.
    • regex - Lines that match this regular expression are included. See also java.util.regex.Pattern
      Defaults to "(?i)\b(error|exception|fatal|fail(ed|ure)|un(defined|resolved))\b".
    • linesBefore - The number of lines to include before the matching line. Lines that overlap with another match or linesAfter are only included once.
      Defaults to 0.
    • linesAfter - The number of lines to include after the matching line. Lines that overlap with another match or linesBefore are only included once.
      Defaults to 0.
    • maxMatches - The maximum number of matches to include. If 0, all matches will be included.
      Defaults to 0.
    • showTruncatedLines - If true , include [...truncated ### lines...] lines.
      Defaults to true.
    • substText - If non null, insert this text into the email rather than the entire line.
  • ${BUILD_NUMBER} - Displays the number of the current build.
  • ${BUILD_STATUS} - Displays the status of the current build. (failing, success, etc...)
  • ${BUILD_URL} - Displays the URL to the current build.
  • ${CHANGES, showPaths , format , pathFormat } - Displays the changes since the last build.
    • showPaths - if true, the paths modified by a commit are shown.
      Defaults to false.
    • format - for each commit listed, a string containing %X, where %X is one of %a for author, %d for date, %m for message, %p for paths, or %r for revision. Not all revision systems support %d and %r. If specified, showPaths is ignored.
      Defaults to "[%a] %m\n".
    • pathFormat - a string containing %p to indicate how to print paths.
      Defaults to "\t%p\n".
  • ${CHANGES_SINCE_LAST_SUCCESS, reverse , format , showPaths , changesFormat , pathFormat } - Displays the changes since the last successful build.
    • reverse - indicates that most recent builds should be at the top.
      Defaults to false.
    • format - for each build listed, a string containing %X, where %X is one of %c for changes, or %n for build number.
      Defaults to "Changes for Build #%n\n%c\n".
    • showPaths , changesFormat , pathFormat - defined as showPaths , format , and pathFormat from ${CHANGES}, respectively.
  • ${CHANGES_SINCE_LAST_UNSTABLE, reverse , format , showPaths , changesFormat , pathFormat } - Displays the changes since the last unstable or successful build.
    • reverse - indicates that most recent builds should be at the top.
      Defaults to false.
    • format - for each build listed, a string containing %X, where %X is one of %c for changes, or %n for build number.
      Defaults to "Changes for Build #%n\n%c\n".
    • showPaths , changesFormat , pathFormat - defined as showPaths , format , and pathFormat from ${CHANGES}, respectively.
  • ${ENV, var } - Displays an environment variable.
    • var - the name of the environment variable to display. If "", show all.
      Defaults to "".
  • ${FAILED_TESTS} - Displays failing unit test information, if any tests have failed.
  • ${HUDSON_URL} - Displays the URL to the Hudson server. (You can change this on the system configuration page.)
  • ${PROJECT_NAME} - Displays the project's name.
  • ${PROJECT_URL} - Displays a URL to the project's page.
  • ${SVN_REVISION} - Displays the subversion revision number.
  • ${CAUSE} - Displays the cause of the build.
  • ${JELLY_SCRIPT, template } - Custom message content generated from a Jelly script template. There are two templates provided: "html" and "text". Custom Jelly templates should be placed in $HUDSON_HOME/email-templates. When using custom templates, the template filename without ".jelly" should be used for the "template" argument.
    • template - the template name.
      Defaults to "html".

 

 

点击后,在Add a Trigger中增加触发邮件的情况。

 

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值