简体   繁体   English

通过api知道哪个构建步骤失败

[英]Know which build step is failed through api

I am trying to find out the details of a build through API. 我正在尝试通过API查找构建的详细信息。 I am using below to get the specific result. 我在下面使用以获得特定结果。 http://localhost:8080/job/test/lastBuild/api/json?pretty=true HTTP://本地主机:8080 /工作/测试/ lastBuild / API / JSON漂亮=真的吗?

Now when the build is failed, I am just getting the status of the build. 现在,当构建失败时,我只是获得了构建的状态。 I want to determine which build step is causing the problem. 我想确定哪个构建步骤导致了问题。 Please let me know how can I get it through api 请让我知道如何通过api获取它

This is a interesting question. 这是一个有趣的问题。

I never found something like this before, since Jenkins just tell you good or bad as you said. 我从来没有发现过这样的事情,因为詹金斯只是说了好还是坏。

A possible solution would be using the Jenkins BFA plugin. 一个可能的解决方案是使用Jenkins BFA插件。

https://wiki.jenkins-ci.org/display/JENKINS/Build+Failure+Analyzer https://wiki.jenkins-ci.org/display/JENKINS/Build+Failure+Analyzer

This plugin can help you auto detect the error based on the error pattern you described in the config. 这个插件可以帮助您根据配置中描述的错误模式自动检测错误。

And then you can collect the detail error info from the jenkins json file. 然后,您可以从jenkins json文件中收集详细错误信息。

Br, BR,

Tim 蒂姆

I have been doing some work on scraping the failed builds out of our Jenkins instance, and then trying to match up failures, including ones categorized by the Build Failure Analyzer, and I can tell you it is a bit frustrating. 我一直在做一些工作,从Jenkins实例中删除失败的构建,然后尝试匹配失败,包括由Build Failure Analyzer分类的失败,我可以告诉你,这有点令人沮丧。

We have three types of builds (FreeStyle, Matrix, and Workflow) and each of them reports things differently. 我们有三种类型的构建(FreeStyle,Matrix和Workflow),每种构建报告的方式都不同。 Tim's comment bout using depth=3 on the API works, but I have been using the more specific: Tim在API上使用depth=3的注释回合有效,但我一直在使用更具体的注释:

https://HOST_NAME/job/PROJECT_NAME/api/json?pretty=true&tree=allBuilds[number,timestamp,url,duration,result,runs[url,number],actions[foundFailureCauses[*]]]

The tree part makes better sure you get all the parts you want (sometimes the depth does not get thing that this does), as well as excluding things you don't. tree部分可以更好地确保您获得了所需的所有部分(有时depth不能做到这一点),并排除了您不需要的部分。 This works for FreeStyle builds, and Workflow builds that terminate with a single node. 这适用于FreeStyle构建和以单个节点终止的Workflow构建。

For Matrix builds you then have to follow the links provided in runs , but you have to munch the URL it gives you (it puts the build number in the wrong place). 对于Matrix构建,您必须遵循runs提供的链接,但是您必须修改它提供的URL(将构建号放在错误的位置)。 Then you call the same API on the linked build to scrape out that one. 然后,您可以在链接的构建中调用相同的API来删除该API。

For Workflow builds there is annoying news, good news, bad news, and even worse news as far as I know. 就Workflow构建而言,据我所知,有烦人的消息,好消息,坏消息,甚至更坏的消息。 The annyoying part is that you have to see that this is a Workflow build (look at the _class property that you got without asking for it), and then look at the build url, but replacing wfapi for api/json (and forgetting the rest of the parameters). 令人讨厌的部分是,您必须看到这是一个Workflow构建(查看不要求它的_class属性),然后查看生成url,但是将wfapi替换为api/json (并忘记了其余部分)参数)。 Then you can follow the json links that you get back form that to locate the failures. 然后,您可以按照json链接的形式查找故障。 The good news is that this gives you a much better link to the failure, including intelligible messages (sometime). 好消息是,这使您可以更好地链接到故障,包括可理解的消息(有时)。

The bad news is that I am not sure that the Build Failure Analyzer is working properly for these, or knows how to mark it on the proper build step. 坏消息是我不确定构建失败分析器是否可以针对这些问题正常运行,或者不确定如何在正确的构建步骤中对其进行标记。

The even worse news is that for a lot of builds on my server this API does not seem to work at all. 更糟糕的消息是,对于我的服务器上的许多构建,此API似乎根本不起作用。 This is even though I can see similar information through the BlueOcean UI. 即使我可以通过BlueOcean UI看到类似的信息。 I am investigating running this down now. 我正在调查此事。

Sorry that this is not a simple answer, but that is the state of things as far as I can tell at this point. 抱歉,这不是一个简单的答案,但就目前而言,这是我所能知道的。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 编写Jenkins groovy脚本-如何确定哪个构建步骤失败 - Writing a Jenkins groovy script — how to determine which build step failed 如何取消jenkins中的构建队列作业,这些作业不是由jenkins启动的,而是通过REST API在其构建队列中 - how to cancel build queue jobs in jenkins, which are not started by jenkins and are in its build queue through REST API 即使构建步骤失败,如何继续Jenkins构建? - How to continue a Jenkins build even though a build step failed? 通过脚本重新触发失败的构建 - Retrigger failed build through a script 如何知道哪个用户回答了Jenkins-Pipeline输入步骤? - How to know which user answered a Jenkins-Pipeline input step? 詹金斯(Jenkins)的工作继续进行先前构建中的最后一个失败步骤 - Jenkins job continue on last failed step in previous build Jenkins-当未执行步骤之一时,Multijob Phase标记生成失败 - Jenkins - Multijob Phase marks build as failed when one of the step is not executed Jenkins Heroku Step War:部署成功,但构建失败 - Jenkins Heroku Step war:deploy success, but build failed 在失败的构建步骤之后,Jenkins为什么不停止处理? - Why doesn't Jenkins stop processing after a failed build step? 访问以前的Jenkins构建中哪个阶段失败 - Access which stage failed in previous Jenkins build
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM