How to export a remote agent capability list to bamboo-capabilities.properties format

お困りですか?

アトラシアン コミュニティをご利用ください。

コミュニティに質問


プラットフォームについて: サーバーと Data Center のみ。この記事は、サーバーおよび Data Center プラットフォームのアトラシアン製品にのみ適用されます。

要約

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 - Getting issue details... STATUS

環境

Bamboo 7.1 以降

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
$ 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
#!/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
$ ./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

最終更新日 2022 年 9 月 3 日

この内容はお役に立ちましたか?

はい
いいえ
この記事についてのフィードバックを送信する
Powered by Confluence and Scroll Viewport.