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

How to pass value from script to MAVEN TASK 3.x

Hemant Sharma September 29, 2023

I am not able to pass values from my script to  maven task 3.x

I am not able to refer the bamboo injected values  under goal section of maven task.
Other bamboo plan variables are accessible  but the Bamboo injected variables are not accessible

2 answers

1 accepted

1 vote
Answer accepted
Eduardo Alvarenga
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
September 30, 2023

Hello @Hemant Sharma

Welcome to Atlassian Community!

Bamboo works normally with variables (native or injected) in Maven 3.x tasks. Can you show how you are declaring and consuming them? Also, let us know the Bamboo version you are using.

Cheers,

Eduardo Alvarenga
Atlassian Support APAC

--please don't forget to Accept the answer if the reply is helpful-- 

Hemant Sharma October 9, 2023

Hi @Eduardo Alvarenga 

Bamboo version 9.2

Script configuaration task
Interpreter - /bin/sh or cmd.exe

script location Inline

FILE_NAME=variables.properties

...

# some code that generates value for below two variables.

...
echo "RELEASECANDIDATE=$RELEASE_CANDIDATE" >> $FILE_NAME
echo "ENVTYPE=$ENV_TYPE" >> $FILE_NAME

echo "**** SCRIPT COMPLETED ****"


Inject Bamboo variables configuration

Path to properties file - variables.properties

 

Namespace: - abcd

Maven 3.x configuration

 -settings ./settings.xml clean deploy -P${bamboo.ENVTYPE} -Denv=${bamboo.ENVTYPE} -Drevision=${bamboo.TAG_FOR_RELEASE}.${bamboo.RUNNING_NUMBER}-${bamboo.RELEASECANDIDATE}

the values ENVTYPE and RELEASECANDIDATE are not resolved.

Eduardo Alvarenga
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
October 9, 2023

Hello @Hemant Sharma

You are missing the namespace declared during the Inject Bamboo variables task. Try:

  • ${bamboo.abcd.VAR_NAME}

Sincerely,

Eduardo Alvarenga
Atlassian Support APAC

--please don't forget to Accept the answer if the reply is helpful-- 

Like Hemant Sharma likes this
Hemant Sharma October 9, 2023

Thanks a lot for the quick response @Eduardo Alvarenga

The solution helped.

Eduardo Alvarenga
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
October 9, 2023

No worries. Make sure to accept the answer so others can benefit.

0 votes
Hemant Sharma October 9, 2023

Hi @Eduardo Alvarenga 

Bamboo version 9.2

Script configuaration task
Interpreter - /bin/sh or cmd.exe

script location Inline

FILE_NAME=variables.properties

...

# some code that generates value for below two variables.

...
echo "RELEASECANDIDATE=$RELEASE_CANDIDATE" >> $FILE_NAME
echo "ENVTYPE=$ENV_TYPE" >> $FILE_NAME

echo "**** SCRIPT COMPLETED ****"


Inject Bamboo variables configuration

Path to properties file - variables.properties

 

Namespace: - abcd

Maven 3.x configuration

 -settings ./settings.xml clean deploy -P${bamboo.ENVTYPE} -Denv=${bamboo.ENVTYPE} -Drevision=${bamboo.TAG_FOR_RELEASE}.${bamboo.RUNNING_NUMBER}-${bamboo.RELEASECANDIDATE}

the values ENVTYPE and RELEASECANDIDATE are not resolved.

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events