Long time stackoverflow reader, first post in a very long time, thanks for all the help over the years!
I'm trying to automate the post release process inside of Bamboo, I have a the following structure in my build plan (upstream):
- Build Project
- Plan
- Default Stage
- Job Build JAR
- Task Git Checkout
- Task Maven
- Task create Git Tag in repo
- Job Build JAR
- Default Stage
- Plan
After building my project I have a successful build with i.E. #14 and the tag 'v5.10.4.1' in ButBucket (Git).
Following this I created a Deployment Project (downstream) that has these script tasks:
- Create fixVersion in Jira
- Gather all the Jira Tickets in the lastest Bamboo Release
- Add all Bamboo Release Tickets to Jira Release
The steps use curl in some form or another and the REST API either from Jira or Bamboo, Step 1 works with any problems as long as the fixVersion hasn't been created in Jira previously.
For Step 2 I did a test from my workstation with success using this command to get the issues and save them as a text file for Step 3 afterwards:
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
I tried doing this as a Script Task during my deployment as either inline or file based, this is my script:
#!/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
I ran into the following problems:
- Using https in the curl command on Bamboo itself will log:
curl: (35) error:1408F10B:SSL routines:ssl3_get_record:wrong version number - Using http in the curl command on Bamboo itself will log a
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>
It seems it is not possible to curl the Bamboo REST API from inside of Bamboo it's self but it should be possible, I found this in the Atlassian documentation:
curl -u <ADMIN_USERNAME>:<PASSWORD> <BAMBOO_URL>/build/admin/ajax/getDashboardSummary.action
Maybe someone has solved this already but I can't find a thread or documentation. Many thanks for help or ideas!
After lots of research (googling was not a help here) I found the "actual" Bamboo REST API documentation with examples of the correct URI:
or as an example of the structure:
In my use case of above where I was trying to
curlthe Bamboo REST API from a Bamboo Script Task, I am now using the following URI without issues:Issue is resolved.