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

Next challenges

Recent achievements

Recognition

  • Give kudos
  • My kudos

Leaderboard

  • Global

Trophy case

Kudos (beta program)

Kudos logo

You've been invited into the Kudos (beta program) private group. Chat with others in the program, or give feedback to Atlassian.

View group

It's not the same without you

Join the community to find out what other Atlassian users are discussing, debating and creating.

Atlassian Community Hero Image Collage

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 votes

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
Community showcase
Published in Bamboo

Bamboo 7.1 is here and is packed with value!

I'm happy to announce that Bamboo 7.1 has been released and it’s overflowing with awesome new features. Top-voted issues First and foremost, a bunch of JAC top voted issues has been delivered - y...

684 views 1 6
Read article

Community Events

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

Find an event

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

Unfortunately there are no Community Events near you at the moment.

Host an event

You're one step closer to meeting fellow Atlassian users at your local event. Learn more about Community Events

Events near you