Created
June 23, 2021 08:37
-
-
Save mrueegg/58a9837185571cf257bf1f2a528e0baa to your computer and use it in GitHub Desktop.
Fetching all plan Java specs for a Bamboo project by REST and storing it in Java files
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env bash | |
# see https://jira.atlassian.com/browse/BAM-20237 for more details | |
BAMBOO_HOSTNAME=$1 | |
BAMBOO_API_TOKEN=$2 | |
PROJECT=$3 | |
json=$(curl "https://${BAMBOO_HOSTNAME}/rest/api/latest/project/${PROJECT}/specs.json" \ | |
--header "Authorization: Bearer ${BAMBOO_API_TOKEN}") | |
for k in $(jq -r '.spec | keys | .[]' <<< $json); do | |
spec=$(jq -r ".spec[$k]" <<< $json) | |
projectKey=$(jq -r '.projectKey' <<< "$spec") | |
buildKey=$(jq -r '.buildKey' <<< "$spec") | |
jq -r '.code' <<< "$spec" | tr '\n' '\0' | xargs -0 printf '%b\n' > "${projectKey}-${buildKey}.java" | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment