How to get Bamboo build number in build.gradle
Asked Answered
E

3

5

I am trying to access the bamboo build number in build.gradle but am unable to access it there. Following are the options 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 creating a variable for my build plan with variable name as BUILD_NUMBER and variable value as ${bamboo.buildNumber} and accessed it using the below methods, but the values are not getting accessed.

System.getenv ()["BUILD_NUMBER"]
project.hasProperty("BUILD_NUMBER")
Everyday answered 10/11, 2015 at 6:56 Comment(0)
E
5

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

Everyday answered 10/11, 2015 at 8:38 Comment(1)
This one worked for me too. System.getenv('bamboo.buildNumber') is not working.Scarlet
K
4

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

System.getenv('bamboo.buildNumber')

Note that this variable should be exported before executing the script. But Bamboo does that for you.

Knitting answered 10/11, 2015 at 7:13 Comment(0)
G
0

Similar to Uday, I used the following.

System.env['bamboo_buildNumber']
Grote answered 19/1, 2017 at 18:20 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.