使用 Bamboo 脚本任务收集最新 Bamboo 版本中的所有 Jira 票据

问题描述 投票:0回答:1

长时间堆栈溢出读者,很长时间以来的第一篇文章,感谢多年来的所有帮助!

我正在尝试自动化 Bamboo 内部的发布后流程,我的构建计划(上游)中有以下结构:

  • 构建项目
    • 计划
      • 默认阶段
        • 作业构建 JAR
          • 任务 Git 签出
          • 任务 Maven
          • 任务在存储库中创建 Git 标签

构建我的项目后,我使用 i.E 成功构建了#14 以及 ButBucket (Git) 中的标签“v5.10.4.1”。

接下来,我创建了一个具有以下脚本任务的部署项目(下游):

  1. 在 Jira 中创建修复版本
  2. 收集最新 Bamboo 版本中的所有 Jira 门票
  3. 将所有 Bamboo Release Ticket 添加到 Jira Release

这些步骤以某种形式使用

curl
以及来自 Jira 或 Bamboo 的 REST API,只要之前未在 Jira 中创建 fixVersion步骤 1 就可以解决任何问题。

对于第 2 步,我在工作站上进行了测试,并成功使用此命令获取问题并将其保存为文本文件,用于随后的第 3 步

curl -X GET --user ${bamboo.user}:${bamboo.password} -H 'X-Atlassian-Token: no-check' "https://server-name/rest/api/latest/result/${bamboo.buildResultKey}.json?expand=jiraIssues" -o >(grep -o -E '"(Ticket-KEY)-\d*"' | tr -d '"' > /tmp/issueKeys.txt) && cat /tmp/issueKeys.txt

我尝试在部署期间将其作为脚本任务作为内联或基于文件执行,这是我的脚本:

#!/bin/bash
 
# Variables: ${bamboo.user}:${bamboo.password}; ${bamboo.buildResultKey}
# Gather all the Jira Tickets in the lastest Bamboo Release as the second step
 
echo "==> Gather all the Jira Tickets in the lastest Bamboo Release: yes"
 
curl -X GET --user ${bamboo.user}:${bamboo.password} -H 'X-Atlassian-Token: no-check' "https://server-name/rest/api/latest/result/${bamboo.buildResultKey}.json?expand=jiraIssues" -o >(grep -o -E '"(Ticket-KEY)-\d*"' | tr -d '"' > /tmp/issueKeys.txt)
 
echo "==> The following Jira Tickets from the lastest Bamboo Release have been gathered"

# for debugging run this to verfiy the results in the Bamboo deployment logs
cd /tmp/ && ls -la && cat issueKeys.txt && nl issueKeys.txt

我遇到了以下问题:

  • 在 Bamboo 本身的 curl 命令中使用 https 将记录:
    curl: (35) error:1408F10B:SSL routines:ssl3_get_record:wrong version number
  • 在 Bamboo 本身的 curl 命令中使用 http 将记录一个
    404
    :
13-Dec.-2023 14:05:53   <!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML 2.0//EN">
13-Dec.-2023 14:05:53   <html><head>
13-Dec.-2023 14:05:53   <title>404 Not Found</title>
13-Dec.-2023 14:05:53   </head><body>
13-Dec.-2023 14:05:53   <h1>Not Found</h1>
13-Dec.-2023 14:05:53   <p>The requested URL was not found on this server.</p>
13-Dec.-2023 14:05:53   <hr>

似乎不可能从 Bamboo 自身内部卷曲 Bamboo REST API,但应该是可能的,我在 Atlassian 文档中找到了这一点:

curl -u <ADMIN_USERNAME>:<PASSWORD> <BAMBOO_URL>/build/admin/ajax/getDashboardSummary.action

也许有人已经解决了这个问题,但我找不到线程或文档。非常感谢您的帮助或想法!

bash rest curl bamboo
1个回答
0
投票

经过大量研究(谷歌搜索在这里没有帮助),我找到了“实际的”Bamboo REST API 文档,其中包含正确 URI 的示例:

http://myhost.com:8085/bamboo/rest/api/latest/plan.json

或者作为结构示例:

http://host:port/rest/api-name/api-version/resource-name

在上面的用例中,我尝试从 Bamboo 脚本任务中使用

curl
Bamboo REST API,我现在使用以下 URI,没有出现问题:

"http://localhost:8085/rest/api/latest/result/${bamboo.buildResultKey}.json?expand=jiraIssues"

问题已解决。

© www.soinside.com 2019 - 2024. All rights reserved.