答案 0 :(得分:0)
我正在使用正在构建的全局管道库执行相同的操作。这对于只想通过电子邮件发送特定故障阶段的日志的情况很有用。希望对您有所帮助。在下面的示例管道中,名为grecaptcha.render(this, {
'sitekey' : {{ google_recaptcha_site_key }}
});
的作业执行了一次(test
)
pipeline { agent any stages{ stage("Compile") { steps { script { echo "Compiling..." } } } stage("Test") { steps { script { echo "Testing..." } } } stage("Build") { steps { script { echo "Building..." } } } } }
访问API以查看执行详细信息。请注意,此JSON的每个对象都包含属性build #1
和id
。
http://localhost:8080/blue/rest/organizations/jenkins/pipelines/test/runs/1/nodes/
[ { *snip* "actions": [], "displayDescription": null, "displayName": "Compile", "durationInMillis": 341, "id": "6", "input": null, "result": "SUCCESS", "startTime": "2018-11-24T18:14:16.196+0800", "state": "FINISHED", "type": "STAGE", "causeOfBlockage": null, "edges": [ { "_class": "io.jenkins.blueocean.rest.impl.pipeline.PipelineNodeImpl$EdgeImpl", "id": "15", "type": "STAGE" } ], "firstParent": null, "restartable": true }, { *snip* "actions": [], "displayDescription": null, "displayName": "Test", "durationInMillis": 246, "id": "15", "input": null, "result": "SUCCESS", "startTime": "2018-11-24T18:14:16.693+0800", "state": "FINISHED", "type": "STAGE", "causeOfBlockage": null, "edges": [ { "_class": "io.jenkins.blueocean.rest.impl.pipeline.PipelineNodeImpl$EdgeImpl", "id": "24", "type": "STAGE" } ], "firstParent": "6", "restartable": true }, { *snip* "actions": [], "displayDescription": null, "displayName": "Build", "durationInMillis": 270, "id": "24", "input": null, "result": "SUCCESS", "startTime": "2018-11-24T18:14:17.188+0800", "state": "FINISHED", "type": "STAGE", "causeOfBlockage": null, "edges": [], "firstParent": "15", "restartable": true } ]
使用result
检查阶段的状态(result
,SUCCESS
,FAILED
等...)
使用ABORTED
进入特定阶段,对于本示例,其中id
为id
的Test阶段的日志。
http://localhost:8080/blue/rest/organizations/jenkins/pipelines/test/runs/1/nodes/15/log/
Testing...
答案 1 :(得分:0)
您可以通过以下网址找到其余的api文档:
https://github.com/jenkinsci/blueocean-plugin/tree/master/blueocean-rest
仍然需要在他们的文档中注意这一点。
Reflection