Problem using deployment (password) variables in task scripts

Is it possible to use password variables in a task shell script?  For example deployment variables have been defined as follows:

Deployment_variables.png

 

And when used in a task script, it does not work (Script body, running on a Linux server):

set -x
echo "********** db.username: ${bamboo_db_username}"
echo "********** db.password: ${bamboo_db_password}"
echo "********** db.admin.username: ${bamboo_db_admin_username}"
echo "********** db.admin.password: ${bamboo_db_admin_password}"
./gradlew $bamboo_sbox_gradle_liquibase_update_arguments -Dorg.gradle.project.db_username=$bamboo_db_username -Dorg.gradle.project.db_password=$bamboo_db_password -Dorg.gradle.project.db_admin_username=$bamboo_db_admin_username -Dorg.gradle.project.db_admin_password=$bamboo_db_admin_password

Results in:

build	24-Mar-2016 06:11:40	********** db.username: pshnt
error	24-Mar-2016 06:11:40	+ echo ********** db.username: pshnt
build	24-Mar-2016 06:11:40	********** db.admin.username: pshnt
build	24-Mar-2016 06:11:40	********** db.admin.password: ********
error	24-Mar-2016 06:11:40	+ echo ********** db.admin.username: pshnt
error	24-Mar-2016 06:11:40	+ echo ********** db.admin.password: ********
error	24-Mar-2016 06:11:40	+ ./gradlew lb-update -PenvironmentName=sbox -Dorg.gradle.project.db_username=pshnt -Dorg.gradle.project.db_password=******** -Dorg.gradle.project.db_admin_username=pshnt -Dorg.gradle.project.db_admin_password=********
build	24-Mar-2016 06:11:55	[buildinfo] Not using buildInfo properties file for this build.
build	24-Mar-2016 06:11:55	:lb-Update
build	24-Mar-2016 06:11:55	liquibase-plugin: Running the 'init' activity...
error	24-Mar-2016 06:11:56	Unexpected error running Liquibase: java.sql.SQLException: ORA-01017: invalid username/password; logon denied

If we define these as global variables, it works fine (but the password show up in the clear in the logs).

Using global variables would make it harder to maintain as we are using global variables to define commons variables to all deployment and use deployment variables that are specific to each app deployment.

What we are trying to achieve is to pass sensitive information for each deployment project.  We could simply do away with the variables and put the values directly in the -D parameters, but our goal is to replace the replace the body of the script with a file so that we can reuse code as much as possible.

Am I missing something obvious / doing this the wrong way?

 

Thanks

1 answer

0 vote

Using bamboo variables only works in inline scripts (the ones you create directly typing in the edit box in the task configuration). If you call a script from a file, you need to use system environment variables. Good news is all bamboo variables are automatically passed as system variables to the script process.

For example instead of ${bamboo.variable} you use $bamboo_variable  (Unix) or %bamboo_variable% (Windows)

Suggest an answer

Log in or Sign up to answer
How to earn badges on the Atlassian Community

How to earn badges on the Atlassian Community

Badges are a great way to show off community activity, whether you’re a newbie or a Champion.

Learn more
Community showcase
Published May 18, 2017 in Bamboo

FAQ: How to Upgrade Bamboo Server

Bamboo 5.9 will no longer be supported after June 12, 2017. What does this mean? As part of our End of Life policy, Atlassian supports major versions for two years after the first major iteratio...

1,581 views 0 6
Read article

Atlassian User Groups

Connect with like-minded Atlassian users at free events near you!

Find a group

Connect with like-minded Atlassian users at free events near you!

Find my local user group

Unfortunately there are no AUG chapters near you at the moment.

Start an AUG

You're one step closer to meeting fellow Atlassian users at your local meet up. Learn more about AUGs

Groups near you