How can Groovy Postbuild check the log message of a previous post-build action

时间:2015-11-12 11:26:24

标签: groovy jenkins

I want to access the log of another post-build action, which runs right before the groovy postbuild.

The console output looks like this:

Build succeeded.
    0 Warning(s)
    0 Error(s)

Time Elapsed 00:00:00.48
Code Metrics Report path: **/*.Metrics.xml
Code Metrics Report Not Found.
Build step 'Record VS Code Metrics PowerTool Report' changed build result to UNSTABLE

I cannot use manager.logContains() because the output was generated by another post-build action.

I can set the build status to SUCCESS, but I want to do it only if the post-build action logged Build step 'Record VS Code Metrics PowerTool Report' changed build result to UNSTABLE

if (manager.build.result == hudson.model.Result.UNSTABLE 
        && ???.contains("Build step 'Record VS Code Metrics PowerTool Report' changed build result to UNSTABLE") {
  manager.build.@result = hudson.model.Result.SUCCESS
}

1 个答案:

答案 0 :(得分:0)

您可以尝试使用xyz: .word -8, 16, -32, 64, -128, 256 # int main(void) # # local variable register # int *p $s0 # int *end $s1 # int min $s2 # int total $s3 # .text .globl main main: la $s0, xyz # p = foo addi $s1, $s0, 24 # end = p + 6 add $s3, $zero, $zero # total = 0 add $s2, $zero, $zero # min = 0 L1: beq $s0, $s1, L2 # if (p == end) goto L2 lw $t0, ($s0) # $t0 = *p lw $t1, ($s2) # $t1 = min slt $t2, $t1, $t0 # check if min is less than p add $s3, $s3, $t0 # total += $t0 bne $t2, $zero, L3 # if min is less than p, go to L3 addi $s0, $s0, 4 # p++ j L1 L2: add $v0, $zero, $zero # return value from main = 0 jr $ra L3: move $s2, $t0 j L1

例如,

manager.build.logFile.readLines()

有关示例,请参阅Oni Dar's excellent answer