Problem using deployment (password) variables in task scripts
Asked by Jacques Boucher:

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: pshnterror	24-Mar-2016 06:11:40	+ echo ********** db.username: pshntbuild	24-Mar-2016 06:11:40	********** db.admin.username: pshntbuild	24-Mar-2016 06:11:40	********** db.admin.password: ********error	24-Mar-2016 06:11:40	+ echo ********** db.admin.username: pshnterror	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-Updatebuild	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  
[](https://community.atlassian.com/t5/Bamboo-questions/Problem-using-deployment-password-variables-in-task-scripts/qaq-p/387031?attachment-id=9073){#link_11676435dbd06c}  
[](/tnckb94959/attachments/tnckb94959/bamboo-questions/12168/1/Deployment_variables.png){#display_11676435dbd06c_0}


Answers:
author: Marcin Gardias
body: 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)