How to get the Bamboo build number in build.gradle

I am trying to access the bamboo build number in build.gradle, but I cannot access it. Below are the options that I have tried so far inside build.gradle :

 System.getenv ()["bamboo.buildNumber"] System.getenv ()["bamboo_buildNumber"] project.hasProperty("bamboo_buildNumber") project.hasProperty("bamboo_buildNumber") 

I even tried to create a variable for my build plan with the variable name BUILD_NUMBER and the variable value as ${bamboo.buildNumber} and accessed it using the methods described below, but the values ​​did not work out.

 System.getenv ()["BUILD_NUMBER"] project.hasProperty("BUILD_NUMBER") 
+5
source share
3 answers

To access the environment variable from the build.gradle script, use the System.getenv () function:

 System.getenv('bamboo.buildNumber') 

Note that this variable must be exported before the script runs. But Bamboo does it for you.

+4
source

I got the value of the variable - System.getenv () ["bamboo_buildNumber"]

+4
source

Like Uday, I used the following.

 System.env['bamboo_buildNumber'] 
0
source

Source: https://habr.com/ru/post/1235597/


All Articles