gpt4 book ai didi

jenkins - 在 Jenkins 中将变量从 shell 传递到 email-ext

转载 作者:行者123 更新时间:2023-12-04 07:24:44 34 4
gpt4 key购买 nike

我有一个 Jenkins 工作,它执行了 shell 部分,其中我有一些变量
动态填充的 BUILD。

构建执行后,我想将此变量传递给 email-ext 插件默认内容以显示其值。

我尝试了几种方法都没有成功:

  • 无法识别在默认内容中传递此 ${BUILD} 值(在此上下文中仅 Jenkins 环境变量可见)
  • 定义了新的 Jenkins 全局环境变量并试图在 shell 上下文中覆盖其初始值,这显然是不可能的

  • 关于如何做到这一点的任何想法?

    最佳答案

    就我而言,我不是管理员,所以我无法安装插件。但是可以通过解决方法来完成。

    Content Token Reference帮助您找到一个有用的工具。

    ${PROPFILE,file="FILENAME",property="PROPERTYNAME"}

    Expands to the value of a property in a property file. The filename is relative to the build workspace root.



    然后将值保存在 Build > Execute Shell 内的属性文件中:
    rm -f ${WORKSPACE}/env.properties
    touch ${WORKSPACE}/env.properties
    store="/opt/current/store"

    echo "store.folder=${store}" >> ${WORKSPACE}/env.properties

    echo "${store}"

    并从 Post-build Actions > Editable Email Notification 阅读和:
    ${PROPFILE,file="env.properties",property="store.folder"}

    关于jenkins - 在 Jenkins 中将变量从 shell 传递到 email-ext,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/15436915/

    34 4 0
    Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
    广告合作:1813099741@qq.com 6ren.com