The issue: How to set the name of the remote agent and configure the agent authentication using the security token
We are building our own image as mentioned here
example Dockerfile
FROM atlassian/bamboo-agent-base:9.1.1
############################
## bamboo remote agent envs
############################
ENV BAMBOO_SERVER="https://bamboo.server"
ENV IGNORE_SERVER_CERT_NAME=true
ENV ALLOW_EMPTY_ARTIFACTS=true
############################
## install Docker in Docker
############################
COPY --from=docker:dind /usr/local/bin/docker /usr/local/bin/
## Install and configure the build server capabilities
COPY ./entrypoint.sh /data/entrypoint.sh
RUN chmod 777 /data/entrypoint.sh
ENTRYPOINT ["/data/entrypoint.sh"]
example entrypoint.sh
#!/bin/bash
## configure bamboo-agent.cfg.xml
cp /data/template.bamboo-agent.cfg.xml /var/atlassian/application-data/bamboo-agent/bamboo-agent.cfg.xml
chmod 644 /var/atlassian/application-data/bamboo-agent/bamboo-agent.cfg.xml
chown bamboo:bamboo /var/atlassian/application-data/bamboo-agent/bamboo-agent.cfg.xml
# set env for bamboo agent authentication
## I'm pulling this value from a secret provider where I have the security toekn value
## https://confluence.atlassian.com/bamboo/agent-authentication-289277196.html
SECURITY_TOKEN=$(echo "${DATA}" | jq -r '."BAMBOO_REMOTE_AGENT_SECURITY_TOKEN"')
## add bamboo SECURITY_TOKEN to environment variable
export SECURITY_TOKEN=$SECURITY_TOKEN
## add bamboo SECURITY_TOKEN to /entrypoint.py from docker-bamboo-agent-base
sed -i -f - /entrypoint.py << EOF
s/SECURITY_TOKEN = env.get(SECURITY_TOKEN_KEY) if env.get(SECURITY_TOKEN_KEY) else BAMBOO_EPHEMERAL_AGENT_DATA_MAP.get(SECURITY_TOKEN_KEY)/SECURITY_TOKEN = '$SECURITY_TOKEN' \nenv[SECURITY_TOKEN] = SECURITY_TOKEN/g
EOF
## SECURITY_TOKEN needs to be set before entrypoint runs from docker-bamboo-agent-base
#sed -i "7 i SECURITY_TOKEN=$SECURITY_TOKEN" /runAgent.sh ## did not work
## entrypoint from docker-bamboo-agent-base
/entrypoint.py --log=INFO
example template.bamboo-agent.cfg.xml
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<configuration>
<buildWorkingDirectory>/var/atlassian/application-data/bamboo-agent/xml-data/build-dir</buildWorkingDirectory>
<agentDefinition>
<name>remote-agent-1</name>
<description>remote-agent-1</description>
</agentDefinition>
</configuration>
No matter what I do I always have to Approve Access to the remote agent as the security token does not get set.
Question: How can I set the Security Token and the Agent Name
EDIT
I did just see the temp file: uuid-temp.properties
cat uuid-temp.properties
#Agent UUID stored here temporarily until the agent is approved
#Thu Apr 27 22:43:25 EDT 2023
agentUuid=598a6816-d40f-4067-aa1d-53c7cefbb7fc
this looks to be the file to populate the in
<configuration>
<buildWorkingDirectory>/var/atlassian/application-data/bamboo-agent/xml-data/build-dir</buildWorkingDirectory>
<agentUuid>598a6816-d40f-4067-aa1d-53c7cefbb7fc</agentUuid>
<agentDefinition>
<id>1234567</id>
<name>remote-agent-1</name>
<description>remote-agent-1</description>
</agentDefinition>
</configuration>
I have not found it but if the Bamboo dev team happen to look at this ticket, would it be possible to implement something like this for the Security Token?
example: create a security-token.properties file as an alternative to the environment variable
NOTE: pseudo example, file doesn't exist
cat security-token.properties
#Agent Security Token stored here to automate the agent authentication
#Thu Apr 27 22:43:25 EDT 2023
securityToken=ac3eq86b587026br1d7b3a1tdecf991b89ycd71u
EDIT
I see the security token is being passed, but it's still not working
INFO:root:Running Bamboo Agent with command '/opt/java/openjdk/bin/java', arguments ['/opt/java/openjdk/bin/java', '-Dbamboo.home=/var/atlassian/application-data/bamboo-agent', '-jar', '/opt/atlassian/bamboo/atlassian-bamboo-agent-installer.jar', 'https://bamboo.server/agentServer', '-t', 'ac3eq86b587026br1d7b3a1tdecf991b89ycd71u']