4

Slowly going crazy with this one, I am trying to inject Bamboo variables into a text file. I have tried many combinations, but to no avail, cannot seem to get my variable to be replaced during the Atlassian Bamboo build process. I'm running Bamboo on Windows.

Any ideas? This is simply a .txt file that is sent along with my build artifacts.

Whilst not ASP.NET specific, I would eventually like to replace some strings in my Web.config file.

As you can see from the output of my vartest.txt file, no variable combinations are being replaced.

%bamboo.test.variable%
%BAMBOO.test.variable%
%BAMBOO.TEST.VARIABLE%
%BAMBOO_TEST_VARIABLE%
%bamboo_test_variable%
${bamboo.test.variable}
%test_variable%
%TEST_VARIABLE%
%TEST.VARIABLE%

This is my setup (according to the documentation they should be accessible via %BAMBOO_TEST_VARIABLE%): enter image description here

Bhargav Rao
  • 41,091
  • 27
  • 112
  • 129
GONeale
  • 25,353
  • 21
  • 101
  • 146

1 Answers1

3

Those variables are only used for replacing task configuration values or accessing them as environmental variables scripts, they are not substituted in all or any of your source files.

You could run a script that does the replacement using some command-line text tool. See How can you find and replace text in a file using the Windows command-line environment? for some examples.

Then in the script, you can replace ${bamboo.CONNSTRING_PASSWORD} (or whatever format you like) in web.config with the environment variable %BAMBOO_CONNSTRING_PASSWORD%.

Community
  • 1
  • 1
CodeCaster
  • 131,656
  • 19
  • 190
  • 236
  • 1
    Thanks for that. Actually just moments ago I read https://confluence.atlassian.com/bamboo/passing-bamboo-variables-to-a-build-script-289277351.html from which explained it's not available during build execution. Darn. But your idea is great, as I can seem to access it as an environment variable, so the PowerShell find replace would work well. Thanks again. – GONeale Sep 16 '15 at 21:31
  • @GONeale scratch that last remark, you should just be able to access those environment variables from PowerShell. – CodeCaster Sep 16 '15 at 21:37