Forums

Articles
Create
cancel
Showing results for 
Search instead for 
Did you mean: 

Cannot reference custom agent capability (system.jdk.jdk-21) as a variable in pipeline script task

Arumugam_ Prasanth
I'm New Here
I'm New Here
Those new to the Atlassian Community have posted less than three times. Give them a warm welcome!
March 11, 2026

I'm using ephemeral agent, there is capability JDK-21.

i've added it in base image 

 

FROM atlassian/bamboo-agent-base:9.6.8-ubi9
RUN /bamboo-update-capability.sh "system.jdk.jdk21" "/app/jdk-21"
I don't want to add this capability on the template, if added other project also builds looking to build ephemeral agent. this is i'm creating for specific project. 

in the pipeline I trying to call the capability like below one 
JAVA_HOME="${bamboo.capability.system.jdk.jdk-21}"

the above setup where working in static agent not in the ephemeral agent.


1 answer

2 votes
Himanshu Tiwary
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Champions.
March 15, 2026

Hi @Arumugam_ Prasanth ,

This is most likely because ephemeral agents work differently from static agents.
 
With ephemeral agents, Bamboo relies on the agent template capabilities when deciding what the agent can provide. So even if you add the JDK capability inside the Docker image, Bamboo may still not expose it the same way unless that capability is also defined on the ephemeral agent template.
 
That is why it may have worked on a static agent but not on an ephemeral one.
 
There is also one important detail in your example:
 
You added:
 
RUN /bamboo-update-capability.sh "system.jdk.jdk21" "/app/jdk-21"
 
But in the pipeline you are trying to use:
 
JAVA_HOME="${bamboo.capability.system.jdk.jdk-21}"
 
Those two names do not match:
 
system.jdk.jdk21
 
system.jdk.jdk-21
 
So even before looking at the ephemeral agent behavior, that variable name difference is a problem.
 
The better approach here is:
 
define the JDK capability on the ephemeral agent template
 
use that capability as a requirement for the job
 
set JAVA_HOME directly in the container image instead of trying to read it from bamboo.capability...
 
For example, in your Dockerfile:
 
ENV JAVA_HOME=/app/jdk-21
ENV PATH=$JAVA_HOME/bin:$PATH
 
That way, your build does not depend on Bamboo exposing the capability variable inside the script task.
 
So in simple terms:
for ephemeral agents, adding the capability only in the image is usually not enough. Bamboo expects those capabilities to be present on the template as well. If you want this only for one project, the usual solution is to create a separate ephemeral agent template for that project rather than trying to avoid template capabilities completely.
 
You could reply with something like this:
 
This happens because ephemeral agents do not behave like static agents when it comes to capabilities. Bamboo uses the ephemeral agent template as the main source of truth, so adding the JDK capability only inside the image is not usually enough.
 
Also, in your example the capability names do not match: you added system.jdk.jdk21 but referenced system.jdk.jdk-21 in the script.
 
The safer solution is to define the JDK capability on the ephemeral template, make the job require it, and set JAVA_HOME directly in the Docker image. If this should apply only to one project, the cleanest way is to use a dedicated ephemeral agent template for that project.

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events