Jenkins Pipeline-如何从并行构建中获取日志
是否可以(如果可以),如何分别获取每个并行步骤的日志输出?
即:
def projectBranches = [:] for (int i = 0; i < projects.size(); i++) {
def _i = i
projectBranches[_i] = {
someFunction(_i)
}
}
parallel projectBranches
现在是否可以获取每个projectBranches [_i]的日志?
回答:
您可以使用Jenkins REST API获取节点:job / test / 1 / api / json?depth = 2
结果应包含以下内容:
{"_class":"org.jenkinsci.plugins.workflow.cps.nodes.StepStartNode","actions":[{},{},{}],"displayName":"Branch: 0","iconColor":"blue","id":"13","parents":["3"],"running":false,"url":"job/test/1/execution/node/13/"},{"_class":"org.jenkinsci.plugins.workflow.cps.nodes.StepStartNode","actions":[{},{},{}],"displayName":"Allocate node : Start","iconColor":"blue","id":"23","parents":["13"],"running":false,"url":"job/test/1/execution/node/23/"},
{"_class":"org.jenkinsci.plugins.workflow.cps.nodes.StepStartNode","actions":[{},{}],"displayName":"Allocate node : Body : Start","iconColor":"blue","id":"33","parents":["23"],"running":false,"url":"job/test/1/execution/node/33/"},
{"_class":"org.jenkinsci.plugins.workflow.cps.nodes.StepAtomNode","actions":[{},{}],"displayName":"Print Message","iconColor":"blue","id":"37","parents":["33"],"running":false,"url":"job/test/1/execution/node/37/"}
因此,对于您的情况,您对分支名称为StepAtomNode的子级(给定名称为0-9)感兴趣。从中,您可以通过简单地将日志添加到控制台输出地址来获得控制台输出地址(例如:job
/ test / 1 / execution / node / 37 / log)。
现在,这里变得有些丑陋,您需要解析html才能从
<pre class="console-output">log here</pre>
以上是 Jenkins Pipeline-如何从并行构建中获取日志 的全部内容, 来源链接: utcz.com/qa/431874.html