I read this post, which seems to indicate that I can access build-specific variables directly from my script, instead of having to pass each one in via the Environment Variable box in the Script Configuration pane in Bamboo. I am not finding this to be the case, and am wondering if I am missing something.

Basically, I want to be able to arbitrarily access all of the following build specific variables via my perl script, which is called in a pre-build script in order to apply these values to the version in our app:








I know that I can use a line similar to the following in the Script Configuration / Environment Variables box:

RESULTSDIR="${bamboo.build.working.directory}/test-reports" BUILDNUM="${bamboo.buildNumber}" etc...

I'd like to not have to include this line every time I use the script in my Bamboo plan. Is there a way to directly access them, as the above mentioned post seems to indicate?

In the Job log there is a note stating that my globals are passed in to the environment of the remote agent that is running the perl script (a Windows box, if it matters). The build-specific variables, however, are not passed in this fashion. I tried to use a build-specific variable in the "Value" field of a global, but not suprisingly, they are not interpolated. (See screen shot).

If I have to manually pass these in everytime I run the script, it's not the end of the world, but if there is something I'm overlooking, I'd love to hear about it.


    CommentAdd your comment...

    2 answers


      Indeed the build-specific variables aren't passed to the script process environment (contrary to the plan/global variables, which are passed).

      Would you like me to raise a feature request on the Bamboo issue tracker?

      1. scottybgood

        Hi Piotr, thanks for the reply. Yes, I would really appreciate it if you would submit this as a feature request!

        For what it's worth, the reason we're needing this is so that our developement builds can pull the Bamboo build #, build key, etc, in order to display it in the application's about box. My script writes these varaible values into a text file which is then used to build the versions info when the MSBuild task gets kicked off.

        Currently, the workaround I'm using is a little clunky. I'm basically passing all build specific variables that I need into the script via environmental variables, then parsing this list, and matching them up to the list of variables in the script that I know I need. Bleck... messy.

        Thank you!


      2. Piotr Stefan Stefaniak [Atlassian]


        Please add yourself as a watcher and vote for that issue, so it will be scheduled sooner.


      CommentAdd your comment...

      I am using environment variables in v5.8.0 (build 5865) so this must be resolved now.

      I am able to get environment variables such as buildNumber from my nant scripts without passing anything.  One gotcha for nant consumers (maybe others consumers too) is that the retrieval id is with an underscore:


      rather than what the documentation states with a period:




        CommentAdd your comment...