Jenkins - 如何将 Email-ext 插件的 "Culprits" 电子邮件列表变量传递给构建步骤?
Jenkins - How do I pass Email-ext plugin's "Culprits" email list variable to a build step?
Culprits 是自上次未损坏构建到现在为止提交更改的用户列表。 Jenkins Email-ext 插件能够在 Post-Build 操作期间向罪魁祸首发送电子邮件。
我想在我的 Jenkins 作业中的 python 脚本构建步骤中使用 Culprits 定义的电子邮件列表。
任何人都可以建议我该怎么做吗?
'culprits' 列表来自 jenkins 中的 SCM 插件,包括自上次成功构建以来提交的所有用户。最终,email-ext 插件从 scm 获取其列表并根据 following heuristic
生成电子邮件地址
The plugin will generate an email address based on the committer's id and an appended "default email suffix" from Jenkins's global configuration page. For instance, if a change was committed by someone with an id "first.last", and the default email suffix is "@somewhere.com", then an email will be sent to "first.last@somewhere.com"
如果您的电子邮件地址有某种模式(他们必须这样做,否则 email-ext 插件将不会生成正确的地址)那么您可以在 groovy 脚本中自己生成它们,例如:
import hudson.model.*
def culprits = build.getCulprits()
def list = culprits.collect{it.getFullName().toLowerCase().replace(" ", ".") + "@mydomain.com"}
此示例会将 "Adam Smith" 之类的罪魁祸首转换为 adam.smith@mydomain.com
但是您可以将对 getFullName()
的调用替换为对 getId()
的调用,并根据需要对其进行操作。例如:
def list = culprits.collect{it.getId().toLowerCase() + "@mydomain.com"}
这是 email-ext 使用的基本格式 - 您可以从 documentation.
中获得完整的用户属性列表
现在您在 groovy 脚本中有了列表,但是如何使该列表可用于您的 python 脚本?这将归结为你习惯做什么。您可以将列表写入您的工作区并从 python 读取它,或者将结果保存到环境变量,甚至将它保存到构建参数。
Culprits 是自上次未损坏构建到现在为止提交更改的用户列表。 Jenkins Email-ext 插件能够在 Post-Build 操作期间向罪魁祸首发送电子邮件。
我想在我的 Jenkins 作业中的 python 脚本构建步骤中使用 Culprits 定义的电子邮件列表。
任何人都可以建议我该怎么做吗?
'culprits' 列表来自 jenkins 中的 SCM 插件,包括自上次成功构建以来提交的所有用户。最终,email-ext 插件从 scm 获取其列表并根据 following heuristic
生成电子邮件地址The plugin will generate an email address based on the committer's id and an appended "default email suffix" from Jenkins's global configuration page. For instance, if a change was committed by someone with an id "first.last", and the default email suffix is "@somewhere.com", then an email will be sent to "first.last@somewhere.com"
如果您的电子邮件地址有某种模式(他们必须这样做,否则 email-ext 插件将不会生成正确的地址)那么您可以在 groovy 脚本中自己生成它们,例如:
import hudson.model.*
def culprits = build.getCulprits()
def list = culprits.collect{it.getFullName().toLowerCase().replace(" ", ".") + "@mydomain.com"}
此示例会将 "Adam Smith" 之类的罪魁祸首转换为 adam.smith@mydomain.com
但是您可以将对 getFullName()
的调用替换为对 getId()
的调用,并根据需要对其进行操作。例如:
def list = culprits.collect{it.getId().toLowerCase() + "@mydomain.com"}
这是 email-ext 使用的基本格式 - 您可以从 documentation.
中获得完整的用户属性列表现在您在 groovy 脚本中有了列表,但是如何使该列表可用于您的 python 脚本?这将归结为你习惯做什么。您可以将列表写入您的工作区并从 python 读取它,或者将结果保存到环境变量,甚至将它保存到构建参数。