【问题标题】:Calling Groovy script from PowerShell and have access to Jenkins internals从 PowerShell 调用 Groovy 脚本并可以访问 Jenkins 内部
【发布时间】:2016-05-02 18:46:03
【问题描述】:

我有一个使用 PowerShell 脚本运行的构建系统。

我希望这些脚本能够执行更改当前构建的descriptionkeepLog 设置等操作。

我目前知道设置这些的唯一方法是使用 groovy 插件和 执行系统 ​​Groovy 脚本

从 Jenkins 调用的 PowerShell 脚本是否可以调用有权访问 Jenkins 内部对象的 Groovy 脚本?

如果没有,还有其他方法可以从 PowerShell 脚本访问内部 Jenkins 对象吗?

我目前正在从 Execute Windows Batch Command 构建步骤调用 PowerShell 脚本。

【问题讨论】:

    标签: powershell jenkins groovy


    【解决方案1】:

    您可以更改或添加到jenkins/jobs/<job name>/builds/<build no.>/build.xml

    <build>
      ...
      <description>Description</description>
      <keepLog>true</keepLog>
      ...
    </build>
    

    我最近体验到build.xml 仅在构建结束后创建,但这对于descriptionkeepLog 来说应该不是问题。您可以创建一个下游作业:

    Jenkins 的 API 中有一个 Build 类继承 Run.setDescription()Run.keepLog() 但我不知道是否可以从 Jenkins 外部访问它。我总是在 Jenkins 中使用 Grovvy 脚本。

    【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多