构建完成后,在状态页面上我可以看到详细信息,例如用户启动、本次运行花费、git 提交等。构建完成后如何向此页面添加内容。我想捕获 checkmarx 扫描结果 Web 链接并将其添加到此状态页面。
我想在扫描运行后或在构建后操作结束时将其作为我的 checkmarx 阶段的一部分。
由于组织限制,我不想安装任何自定义插件
我尝试了以下方法,但没有成功:
// Groovy Postbuild Script
import hudson.model.*
def build = manager.build
def customMessage = "Custom message: " // my checkmarx link here
def changeSet = build.changeSet
def changes = changeSet.getItems().collect {
"${it.author.fullName}: ${it.msg}"
}.join('\n')
def newContent = """
<div>
<h3>Custom Information:</h3>
<p>${customMessage}</p>
<h3>Changes:</h3>
<pre>${changes}</pre>
</div>
"""
def action = new ParametersAction([
new StringParameterValue('CustomInformation', newContent)
])
build.addAction(action)
非常感谢这方面的任何帮助
您走在正确的轨道上,向构建添加 some 类型的 Action 是第一步。操作与
build.xml
文件中的其余构建信息一起保留。然后,该操作将使用只能来自 Jenkins 核心或插件之一的相应视图显示在构建摘要页面上。您无法将该视图作为管道或共享库的一部分提供。
我知道的唯一一个仅使用 Jenkins 核心就能显示 some 任意文本的视图是
InterruptedBuildAction
。它仅限于纯文本,因此没有链接或任何类型的格式,并且它会在消息前面加上 Exception:
。
import jenkins.model.InterruptedBuildAction
import org.jenkinsci.plugins.workflow.steps.ExceptionCause
def call(Collection<String> messages) {
def build = currentBuild.rawBuild
def causesOfInterruption = messages.collect {
new ExceptionCause(new Throwable(it))
}
def action = new InterruptedBuildAction(causesOfInterruption)
build.addAction(action)
build.save()
}
尝试一下,如果这些限制让您太烦恼,您将不得不安装某种插件。我会推荐徽章。