Groovy脚本查找jenkins的构建状态 [英] Groovy script to find build status of jenkins
本文介绍了Groovy脚本查找jenkins的构建状态的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在使用groovy脚本来获取当前正在运行的jenkins作业的构建状态,作为构建后的动作,例如:
I am using groovy script to get the build status of a jenkins job running currently as a post build action, like this:
def result = manager.build.result
manager.listener.logger.println "And the result is: ${result}"
现在我想将结果"变量的值发送到文件中的特定位置
由于我对groovy不熟悉,所以我并不了解,有没有办法像在shell脚本中那样实现这一目标:
Now I want to send the value of "result" variable to a specific location in a file
Since I am new to groovy, I don't know much, Is there a way to achieve this, like we do in shell scripts:
echo $result > file
推荐答案
如果只想向文件写入一行,则可以使用下一个调用:
If you want to just write a line once to the file you can use next call:
new File("file").write(result)
这篇关于Groovy脚本查找jenkins的构建状态的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文