简体   繁体   English

如何通过 REST API 从 Bamboo Atlassian 构建计划中检索我的自定义变量

[英]How do I retrieve my custom variables from a Bamboo Atlassian Build Plan via REST API

I have a bamboo plan that runs on every commit to a github pull request.我有一个竹子计划,它在每次提交 github 拉取请求时运行。 In that bamboo plan there are a few custom variables on it such as Git Sha, Github Pull Request Number, etc.在那个竹子计划中有一些自定义变量,例如 Git Sha、Github Pull Request Number 等。

I want to write a script that stops all previous builds (multiple concurrent builds) that have the same pull request number -- same custom variable value.我想编写一个脚本来停止所有具有相同拉取请求编号的先前构建(多个并发构建)——相同的自定义变量值。

The reason for this is that if someone makes a quick change to their pull request (comments on the review, etc) that we don't have multiple builds running when only the last one is necessary.这样做的原因是,如果有人对他们的拉取请求(评论评论等)进行了快速更改,那么我们不会在只需要最后一个构建时运行多个构建。

I know it is possible to stop a build with a rest request, but I need a way to be able to get all running builds with custom variable value = 27 (pull request number).我知道可以通过休息请求停止构建,但我需要一种方法来使用自定义变量值 = 27(拉取请求编号)获取所有正在运行的构建。 Once I know this, I can proceed.一旦我知道这一点,我就可以继续了。

At the time of writing, the REST API documentation doesn't list any method of querying the running builds for a particular build variable.在撰写本文时, REST API 文档未列出任何查询特定构建变量的正在运行的构建的方法。

A solution would be to create your own plugin for Bamboo that exposes a REST service that does this query for you, but I don't know which of the Java APIs you would need to use in order to perform that query.一个解决方案是为 Bamboo 创建您自己的插件,该插件公开一个为您执行此查询的 REST 服务,但我不知道您需要使用哪些 Java API 来执行该查询。

Here is how I solved this ...这是我解决这个问题的方法......

You can call /rest/api/latest/result/<plankey>-latest?includeAllStates=true&expand=variables where plankey is the key for the specific Bamboo build plan.您可以调用/rest/api/latest/result/<plankey>-latest?includeAllStates=true&expand=variables其中plankey是特定 Bamboo 构建计划的关键。

You then loop through the results you get back, looking for a lifeCycleState value that is not Finished , and a custom variable with the desired name to see if it matches the PR number you have.然后,您遍历返回的结果,查找不是FinishedlifeCycleState值,以及具有所需名称的自定义变量,以查看它是否与您拥有的 PR 编号匹配。

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

相关问题 如何通过 curl 使用他们的 rest api 从 Nexus 检索工件校验和? - How do I retrieve an artifact checksum from Nexus using their rest api via curl? 无法使用REST API从Bamboo检索结果 - Cannot retrieve results from Bamboo using REST API 如何使用Atlassian Crowd REST API向用户添加多个组? - How do I add multiple groups to a user with the Atlassian Crowd REST API? 您如何使用他们的 REST api 向 Atlassian confluence 发表评论? - How do you post a comment to Atlassian confluence using their REST api? Bamboo REST API访问手动覆盖的变量 - Bamboo REST API access manually overridden variables 我可以使用 Bamboo Rest - API 下载 Bamboo 构建的工件吗? - Can I download Bamboo built artifacts using Bamboo Rest - API? 如何通过Bamboo API获取计划中的测试统计信息 - How to get the statistics of tests in a plan through Bamboo API 如何从 Acumatica 中的 REST API 中检索日记帐交易的货币详细信息? - How do I retrieve the currency details of a journal transaction from the REST API in Acumatica? 通过REST API调用从成功的jenkins作业中检索自定义变量 - Retrieve custom variable from a successful jenkins job run via REST api call 如何检索在VSTS中触发构建时使用的构建参数(使用REST API)? - How can I retrieve the build parameters used when a build was triggered in VSTS (using the REST API)?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM