【问题标题】:How to add a hyperlink in jenkins build description using scripted pipeline如何使用脚本管道在詹金斯构建描述中添加超链接
【发布时间】:2021-12-15 19:01:18
【问题描述】:

使用 jenkins 构建描述插件我想打印我的网络驱动器的路径。

以下代码运行良好。


        stage('print') {
            env.SMBuildDescription="Build path:"+"${buildpath}"
            currentBuild.description=SMBuildDescription
        }

但我想将构建路径添加为超链接。

【问题讨论】:

    标签: java html jenkins groovy jenkins-pipeline


    【解决方案1】:

    试试这个:

    stage('print') {
                currentBuild.description = """Build path: <a href="${buildpath}">Link</a> """
            }
    

    这仅在您的 Jenkins 实例的 /configureSecurity/ 下将 Markup Formatter 设置为 Safe HTML(而不是 Plain text)时才有效。

    【讨论】:

    • 这只是在我们尝试时打印超链接文本..
    • 我刚刚编辑了答案:标记格式化程序设置需要是安全 HTML 才能工作(在配置全局安全性下)。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2017-09-06
    • 2021-09-13
    • 2018-12-18
    相关资源
    最近更新 更多