How to export a remote agent capability list to bamboo-capabilities.properties format
Platform Notice: Data Center Only - This article only applies to Atlassian products on the Data Center platform.
Note that this KB was created for the Data Center version of the product. Data Center KBs for non-Data-Center-specific features may also work for Server versions of the product, however they have not been tested. Support for Server* products ended on February 15th 2024. If you are running a Server product, you can visit the Atlassian Server end of support announcement to review your migration options.
*Except Fisheye and Crucible
Summary
Bamboo allows the user to configure remote agent capabilities using bamboo-capabilities.properties file. That file needs to be created manually and uploaded to each remote agent.
This KB will cover the export of a capability list from a/many Agent(s) to ease the creation of that file in an automatic way.
There is a feature request to add the export function directly to the Bamboo UI BAM-16513 - Clone agent capabilities
Solution
Environment
Bamboo 7.1 or later
Using the REST API
You can use the REST API to find details about a specific agent. The example below requests all capabilities for the Agent ID 4423681 and pipes it to jq to refactor and organise the output as per the bamboo-capabilities.properties format.
REST API example
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
$ curl -s -k -X GET -u admin:admin "https://bamboo80.mydomain.net/rest/api/latest/agent/4423681/capability" | jq -r '.[] | .key|=gsub(" "; "\\ ") | .value|=gsub("\\\\";"\\\\") | [.key, .value] | join("=")'
system.jdk.JDK\ 1.8.0_312=/usr/lib/jvm/java-1.8.0-openjdk-1.8.0.312.b07-1.el7_9.x86_64
DevOps\ -\ Infrastructure=
system.git.executable=/opt/rh/rh-git227/root/usr/bin/git
system.builder.npm.Npm=/opt/rh/rh-nodejs14/root/usr/lib/node_modules/npm
system.builder.mvn3.Maven\ 3=/opt/rh/rh-maven35/root/usr/share/maven
system.jdk.JDK\ 1.6-super\ Super\ duper=C:\\Java 1.6\\jdk1.6 super
system.jdk.JDK=/usr/lib/jvm/java-1.8.0-openjdk-1.8.0.312.b07-1.el7_9.x86_64
system.builder.node.Node.js=/opt/rh/rh-nodejs14/root/usr/bin/node
system.builder.allure.Allure\ 2.3.1=/usr/bin/uptime
system.builder.maven.Artifactory\ Maven\ 3=/opt/rh/rh-maven35/root/usr/share/maven
system.jdk.JDK\ 1.8=/usr/lib/jvm/java-1.8.0-openjdk-1.8.0.312.b07-1.el7_9.x86_64
system.jdk.JDK\ 1.6=C:\\Program Files\\Java\\jdk6.0.17
system.docker.executable=/bin/docker
remote_agent=true
Dumping all agent capabilities using a script
You can use the following script to automate the creation of a per-Agent bamboo-capabilities.properties
file. The script will create one file per agent on the current working directory.
The following script requires curl and jq 1.6 or later
REST API script
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
#!/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
Rest API script demo
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
$ ./extract_capabilities.sh
$ ls -1 bamboo-capabilities.properties*
bamboo-capabilities.properties-agent7
bamboo-capabilities.properties-bamboo-agent-80-corretto
$ cat bamboo-capabilities.properties-bamboo-agent-80-corretto
DevOps\ -\ Infrastructure=
remote_agent=true
system.builder.allure.Allure\ 2.3.1=/usr/bin/uptime
system.builder.maven.Artifactory\ Maven\ 3=/opt/rh/rh-maven35/root/usr/share/maven
system.builder.mvn3.Maven\ 3=/opt/rh/rh-maven35/root/usr/share/maven
system.builder.node.Node.js=/opt/rh/rh-nodejs14/root/usr/bin/node
system.builder.npm.Npm=/opt/rh/rh-nodejs14/root/usr/lib/node_modules/npm
system.docker.executable=/bin/docker
system.git.executable=/opt/rh/rh-git227/root/usr/bin/git
system.jdk.JDK\ 1.6=C:\\Program Files\\Java\\jdk6.0.17
system.jdk.JDK\ 1.6-super\ Super\ duper=C:\\Java 1.6\\jdk1.6 super
system.jdk.JDK\ 1.8.0_312=/usr/lib/jvm/java-1.8.0-openjdk-1.8.0.312.b07-1.el7_9.x86_64
system.jdk.JDK\ 1.8=/usr/lib/jvm/java-1.8.0-openjdk-1.8.0.312.b07-1.el7_9.x86_64
system.jdk.JDK=/usr/lib/jvm/java-1.8.0-openjdk-1.8.0.312.b07-1.el7_9.x86_64
Was this helpful?