【问题标题】:How to refernce groovy script in Jenkins Email-Ext如何在 Jenkins Email-Ext 中引用 groovy 脚本
【发布时间】:2017-12-14 02:54:51
【问题描述】:

如果 groovy 脚本输出为真,我需要触发电子邮件通知, 我这样做是通过添加一个脚本 - 在构建触发器到电子邮件外部触发器并将我的脚本作为 ${SCRIPT, template="myscript.groovy"} 在脚本 - 构建之后 - > Groovy 脚本块中, 保存此配置后出现此错误。

startup failed:
Script1.groovy: 1: unexpected token: SCRIPT @ line 1, column 3.
   ${SCRIPT, template="myscript.groovy"}
     ^

1 error 

我是从电子邮件分机网站获得的

使用模板参数等于你的脚本标记 模板文件名,或者另外的脚本参数等于 自定义脚本名称。例如,如果模板文件名是 foob​​ar.template,电子邮件内容看起来像这样 ${SCRIPT, 模板="foobar.template"}。

https://wiki.jenkins.io/display/JENKINS/Email-ext+plugin#Email-extplugin-Scriptcontent

【问题讨论】:

    标签: jenkins groovy email-ext


    【解决方案1】:

    我自己找到了答案,原来那个块不是用于脚本参考的,是用于脚本的,我把我的 Groovy Script 放在那个块中并且它起作用了。

    【讨论】:

    • 好像这个块(Script - After Build -> Groovy Script )是针对脚本内容,而不是脚本引用,据我所知,没有办法通过名称来引用脚本,您必须将脚本直接放在块中。
    • 想通了:def emailSubject = "${currentBuild.result}: ${currentBuild.projectName} - Build ${currentBuild.number}" emailext body: '${JELLY_SCRIPT,template="html "}',主题:emailSubject,收件人:'${EMAIL_TO}',mimeType:'text/html'
    猜你喜欢
    • 2021-04-27
    • 2015-11-05
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多