Jenkins Email-ext Pre-send Script

帅比萌擦擦* 提交于 2019-12-12 08:47:56

问题


I want to edit email body in pre-send script in Email-ext Jenkins plugin. What language should I use to write code? Bash script or other? Can you add some piece of code? Thanks.


回答1:


The language you must use is Groovy, you can test your piece of code in the script console under Jenkins > Manage > script for anything that doesn't rely on build specific values.

Example that cancels sending the email if there have been no changes (tested when using Git):

if (build.changeSet.emptySet) cancel=true;

Groovy is some sort of convenient scripting language that really uses Java behind the scenes, so you'll probably have to dig into the Jenkins java classes to see what is defined/what objects you can use. For instance the build variable in my sample code is really the java object FreeStyleBuild when I run it on my Jenkins job (which is a free style build job obviously).



来源:https://stackoverflow.com/questions/11967191/jenkins-email-ext-pre-send-script

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