如何在jenkins文件系统上放置Email-Ext groovy脚本 [英] How to place Email-Ext groovy script on the jenkins file system

查看:1865
本文介绍了如何在jenkins文件系统上放置Email-Ext groovy脚本的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要根据构建动态修改通知电子邮件收件人,所以我使用groovy脚本。我想要这个脚本可用于所有作业,所以我想要它驻留在Jenkins文件系统,而不是在每个项目。它可以在收件人字段(使用$ {SCRIPT,...})中或在预发送脚本中。

I need to dynamically modify the notification e-mail recipients based on the build, so I'm using a groovy script. I want this script to be available to all jobs, so I want it to reside on the Jenkins file system and not within each project. It can be either in the recipients fields (using ${SCRIPT,...}) or in the pre-send script. A short (fixed) script that evaluates the master script is also good, as long it is the same for all projects.

推荐答案

一个简短的(固定)脚本评估主脚本也很好。您应该尝试 配置文件提供程序 插件。它与Jenkins的凭据配置一起使用。

You should try Config File Provider plugin. It works together with the Credentials configuration of Jenkins.


  • 转到管理Jenkins > 受管理文件

  • 点击添加新配置

  • 选择 Groovy文件

  • 输入您的脚本内容

  • Go to Manage Jenkins > Managed files
  • Click Add a new Config
  • Select Groovy file
  • Enter the contents of your script

在您的工作配置中:


  • 构建环境

  • 选中提供配置文件

  • 选择已配置的groovy 文件从下拉菜单中选择

  • 使用名称设置变量,例如: myscript
  • Under Build Environment
  • Check Provide Configuration file
  • Select your configured groovy File from dropdown
  • Set Variable with a name, for example: myscript

现在,你工作中的任何地方,你可以说 $ {myscript} 并且它将引用文件系统上的文件的绝对位置(它将位于Jenkins目录中的某处)。

Now, anywhere in your job, you can say ${myscript} and it will refer to absolute location of the file on filesystem (it will be somewhere in Jenkins dir).

这篇关于如何在jenkins文件系统上放置Email-Ext groovy脚本的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆