Pipeline Log API 的各种使用
提示
通过使用 Pipeline Log API,可以更轻松地获取流水线运行日志,从而提高流水线的可读性和可维护性,便于二次开发
获取pipeline各个节点(stage)的log
WfAPI
先获取node:https://<server>/job/<jobname>/job/dev/257/wfapi/describe
再根据node获取log
https://<server>/job/<jobname>/job/dev/257/execution/node/7/wfapi/log
Blue Rest API
先获取node:https://<server>/blue/rest/organizations/jenkins/pipelines/<jobname>/dev/runs/257/nodes/
再根据node获取log(这里获取到的是纯文本格式)
https://<server>/blue/rest/organizations/jenkins/pipelines/<jobname>/dev/runs/257/nodes/6/log/
获取pipeline所有节点聚合的实时log
下面两种方式结果相同,都是文本格式的log
WfAPI
url地址构造:https://<server>/job/<jobname>/job/dev/257/consoleText
Blue Rest API
url地址构造:https://<server>/blue/rest/organizations/jenkins/pipelines/<jobname>/dev/runs/257/log/?start=0