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

How to access buildKey bamboo variable in the atlassian-plugin.xml

Nikita Bedmutha June 15, 2018

I need to paas the buildKey as a query parameter to the link defined in the web-item in atlassian-plugin.xml. currently I am passing the planKey, however it fails to load the Results saying the Plan XYZ not found. When I manually alter the URL, the report is rendered.

<link linkId="XYZ">/build/result/ViewBuildReport.action?planKey=${planKey}&amp;buildNumber=${buildNumber}</link>

 

here the plan key that is generated is PROJ1-PLAN1 ,the report however fails to laod, saying PROJ1-PLAN1 not found. When I manually change the URL to PROJ1-PLAN1-JOB1 , the reports are rendered. This problem is occuring in Bamboo 5.9.7 version and not on latest.

In order to get the URL in the form PROJ1-PLAN1-JOB1 , I need to get the right bamboo variable, buildKey can get the value, but it is returning empty null string. I tried using buildKey=${buildKey} or buildKey=${bamboo.buildKey}, nothing works.So how to get this to work? I am not able to process the artifacts directory also due to this issue.

 

2 answers

0 votes
Ali Karaca November 7, 2019

@Nikita Bedmutha I've same error did you find any solution?

btw i'm trying to put a link for a report in atlassian-pom.xml

 

If you select a job name in left menu which is

 section="results.subMenu/results" -> buildKey = ABP-PLAN-JOB1-3

 

But in opening screen of a build, if you don't select anything then 

section="chainResults.subMenu/chainResults" -> buildKey = ABP-PLAN

0 votes
Steffen Opel _Utoolity_
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
June 15, 2018

This should work conceptually, are you correctly passing the variable to the builder? This is a required step that's easy to forget, see Passing Bamboo variables to a build script:

Bamboo global and build specific variables can be referred to in build scripts or maven pom.xml. Bamboo variables are not directly available in the builder execution context however. They can be passed as parameters to the builder. [emphasis mine]

So for e.g. Maven you'd need something like this to reference the Bamboo variable ${bamboo.buildNumber} as a Maven property ${bambooBuildNumber} within a file processed by the build (more details):

clean package -DbambooBuildNumber=${bamboo.buildNumber}
Nikita Bedmutha June 15, 2018

Thanks Steffen, but yes, I am using it correctly as ${buildKey} in my bamboo plugin's atlassian-plugin.xml. This gives value as PROJ1-PLAN1, but what I expect for my report is PROJ1-PLAN1-JOB1, the full buildKey and not planKey. But it gives PROJ1-PLAN1 only for buildKey also. As a result, Bamboo throws error 'An unexpected error occured', PROJ1-PLAN1 not found. If I hit the URL with query string PROJ1-PLAN1-JOB1, that works fine.

 

Also, I tried injecting variables but they are not accessible too from within atlassian-plugin.xml

Steffen Opel _Utoolity_
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
June 15, 2018

I see, sorry I misread your question - to further clarify the issue:

  1. Your two statements "buildKey can get the value, but it is returning empty null string" and now "${buildKey} [...] gives value as PROJ1-PLAN1" seem to contradict each other?
  2. Does your statement "This problem is occurring in Bamboo 5.9.7 version and not on latest" mean that it works correctly with say Bamboo 6.5.0?
Nikita Bedmutha June 17, 2018

1. Sorry for the confusion, but ${buildKey} returns value as 'PROJ1-PLAN1'.

2. Yes, this problem occurs in 5.9.7. So when tried same on 6.5.0, ${buildKey} returns same PROJ1-PLAN1, but it renders the contents of the action correctly, while in 5.9.7, URL built using this value says, PROJ1-PLAN1 not found i.e.<PLAN_KEY> not found. And on manually changing the URL to PROJ1-PLAN1-JOB1, it renders the contents of the action web item. On 6.5.0, contents are rendered correctly for both values w/ and w/o JOB1. 

So I was searching for some bamboo variable which will give me value PROJ1-PLAN1-JOB1, but I tried almost all available in documentation, but none of them works as required. Also I am not sure, but can this issue be due to change in directory structure for the artifacts which was introduced post 5.9.?

Nikita Bedmutha June 17, 2018

My web item action is the ViewBuildResults calss which is used to render some reports generated during build step.

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events