【发布时间】:2017-02-13 22:29:02
【问题描述】:
我是 Jenkins 的新手,我想从 jenkins 控制台输出中过滤掉仅通过 jenkins 作业运行的 unix 脚本的 json 输出 为了简化我的场景,我有一个返回 json 输出的 MyScript unix 脚本。 jenkins 作业使用“执行 shell”构建操作包装 MyScript 执行。 当我运行 jenkins 作业时,MyScript 被执行并且 jenkins 控制台输出返回以下输出:
Started by remote host ...
Building remotely on ... in workspace ...
Set build name.
New build name is '#11-/products/software/myScript.py'
[ScriptWrapper] $ /bin/sh -xe /tmp/hudson9139846468482145951.sh
+ /products/software/myScript.py -t ...
{'ip': '...', 'host': '...'}
Set build name.
New build name is '#11-/products/software/myScript.py'
Variable with name 'BUILD_DISPLAY_NAME' already exists, ...
Finished: SUCCESS
从上面的输出中,我想只过滤掉我的 unix 脚本的 json 输出,即 "{'ip': '...', 'host': '...'}" 。 当我们通过 REST API 调用 jenkins 作业时需要它,并且我们只需要获取被调用的 unix 脚本的 json 输出:
curl -s -k -u ... --request GET "https://<jenkins uri>/jenkins/view/ScriptWrapper/job/ScriptWrapper/19/consoleText"
我们尝试定义解析规则文件,但这样我们只能在“Parsed Console Output”jenkins 视图中突出显示控制台输出中的某些行。 此外,似乎无法通过 rest api 访问此“Parsed Console Output”:
curl -s -k -u ... --request GET "https://<jenkins uri>/jenkins/view/ScriptWrapper/job/ScriptWrapper/19/parsed_console"
-> 不行
有没有办法过滤掉詹金斯控制台输出? 我们还在评估使用 Jenkins Groovy Postbuild 插件的可能性。你认为它有帮助吗? 提前感谢您的任何建议。
【问题讨论】: