Problem using deployment (password) variables in task scripts

Jacques Boucher March 24, 2016

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 votes
Marcin Gardias
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
April 13, 2016

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
TAGS
AUG Leaders

Atlassian Community Events