Create
cancel
Showing results for 
Search instead for 
Did you mean: 
Sign up Log in

extract_capabilities.sh script throws error

William Flow October 4, 2022

I use the script found at https://confluence.atlassian.com/bamkb/how-to-export-a-remote-agent-capability-list-to-bamboo-capatilities-properties-format-1108676050.html

 

#!/bin/bash
USER=admin
PASS=admin
BAMBOO_SERVER="https://bamboo80.mydomain.net"
CURL="curl -s -k -X GET"
DELIMITER="@#CaPaBiliTy#@" # Set this to a string you know that will not appear on any Agent name
AGENTS=$(${CURL} -u ${USER}:${PASS} "${BAMBOO_SERVER}/rest/api/latest/agent/remote" | jq -r '.[] | .name|=gsub(" "; "_") | [.id, .name] | join('\"${DELIMITER}\"')')

get_capability() {
  ${CURL} -u ${USER}:${PASS} "${BAMBOO_SERVER}/rest/api/latest/agent/${1}/capability" \
    | jq -r '.[] | .key|=gsub(" "; "\\ ") | .value|=gsub("\\\\";"\\\\") | [.key, .value] | join("=")' | sort
}

for AGENT in ${AGENTS[@]}; do
  agent=(${AGENT/${DELIMITER}/ });
  get_capability ${agent[0]} > bamboo-capabilities.properties-${agent[1]}
done

I edit it with my username, password, and site, set it as an executable then run it and get error:

parse error: Invalid numeric literal at line 1, column 10

 

Shouldn't something you post on your site work out of the box?

1 answer

1 accepted

0 votes
Answer accepted
Eduardo Alvarenga
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
October 4, 2022

Hello @William Flow

That's a jq message. It means the input is not the one expected by the filter. Have you tried running each part of the script individually without piping it to jq and seeing the results?

As noted on the page, that script requires jq 1.6. Make sure to use that version or later.

Best regards,

Eduardo Alvarenga
Atlassian Support APAC

--please don't forget to Accept the answer if the reply is helpful-- 

William Flow October 5, 2022

I checked it looked right but no problem I re-wrote the script to make it work

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events