简体   繁体   English

我可以使用 Bamboo Rest - API 下载 Bamboo 构建的工件吗?

[英]Can I download Bamboo built artifacts using Bamboo Rest - API?

This page states:页面指​​出:

Bamboo's REST APIs provide the following capabilities: Bamboo 的 REST API 提供以下功能:

  • Retrieve the artifacts for a build.检索构建的工件。

and here I see the documentation:在这里我看到了文档:

http://myhost.com:8085/bamboo/rest/api/latest/plan/ {projectKey}-{buildKey}/artifact [GET] http://myhost.com:8085/bamboo/rest/api/latest/plan/ {projectKey}-{buildKey}/artifact [GET]

When I try this link with the bamboo server I have, like:当我在我拥有的竹服务器上尝试此链接时,例如:

https://my.bamboo.server/rest/api/latest/plan/MY-PLAN/artifact

All I get is:我得到的是:

<artifacts expand="artifacts">
    <link href="http://my.bamboo.server/rest/api/latest/plan/MY-PLAN/artifact" rel="self"/>
    <artifacts start-index="0" max-result="0" size="0"/>
</artifacts>

So am I understanding the REST documentation completely wrong, or is there something wrong possibly with MY-PLAN and this link is supposed to provide me a war file as I expect?那么我对 REST 文档的理解是完全错误的,还是 MY-PLAN 可能有问题,这个链接应该像我期望的那样为我提供一个战争文件?

I'm afraid you are misunderstanding the REST documentation;恐怕您误解了 REST 文档; by "Retrieve the artifacts for a build", it means "retrieves information about the build artifacts defined for a given plan".通过“检索构建的工件”,它的意思是“检索有关为给定计划定义的构建工件的信息”。 As you have already seen, all you get back is an XML or JSON document describing the artifacts defined.正如您已经看到的,您返回的只是一个描述定义的工件的 XML 或 JSON 文档。

If you want to download an actual build artifact, you'll need to write a script that uses /rest/api/latest/result/ to get the latest successful build info and, from that, form an actual download link to the artifact.如果要下载实际的构建工件,则需要编写一个脚本,该脚本使用 /rest/api/latest/result/ 获取最新的成功构建信息,并从中形成指向该工件的实际下载链接。

有一些与您的问题相关的问题: https ://jira.atlassian.com/browse/BAM-11706 和 BAM-16315(已删除,因为它包含客户详细信息)

Here is the rest api documentation这是其余的api文档

https://docs.atlassian.com/atlassian-bamboo/REST/latest

Search for "/latest/result" documentation搜索“/latest/result”文档

http://myhost.com:8085/rest/api/latest/result/{projectKey}-{buildKey}-{buildNumber : ([0-9]+)|(latest)} [GET]

Example xml request示例 xml 请求

https://bamboo.server.com/rest/api/latest/result/projectKey-buildKey-buildNumber?expand=artifacts

Example json request示例 json 请求

https://bamboo.server.com/rest/api/latest/result/projectKey-buildKey-buildNumber.json?expand=artifacts

Parse the artifacts node in the response.解析响应中的工件节点。 Each artifact should have an href property.每个工件都应该有一个 href 属性。 Pass the href to curl to download the artifact.将 href 传递给 curl 以下载工件。 You will probably need to setup a Bamboo token for rest api authentication.您可能需要为 rest api 身份验证设置一个 Bamboo 令牌。

Example curl request示例卷曲请求

curl -X GET -H "Authorization: Bearer ${BAMBOO_TOKEN}" $ARTIFACT_HREF

You've the link你有链接

<link href="http://my.bamboo.server/rest/api/latest/plan/MY-PLAN/artifact" rel="self"/>

Using curl you can download the artifact.使用 curl 您可以下载工件。

curl --user ${username}:{password} http://my.bamboo.server/rest/api/latest/plan/MY-PLAN/artifact

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

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM