How to parameterize Bamboo builds?
Asked Answered
P

1

7

Please note, although my specific example here involves Java/Grails, it really applies to any type of task available in Bamboo.

I have a task that is a part of a Bamboo build where I run a Java/Grails app like so:

grails run-app -Dgrails.env=<ENV>

Where "<ENV>" can be one of several values (dev, prod, staging, etc.). It would be nice to "parameterize" the plan so that, sometimes, it runs like so:

grails run-app -Dgrails.env=dev

And other times, it runs like so:

grails run-app -Dgrails.env=staging

etc. Is this possible, if so, how? And does the REST API allow me to specify parameter info so I can kick off different-parameterized builds using cURL or wget?

Priscillaprise answered 7/5, 2014 at 1:21 Comment(2)
What and how will you change that variable?Hemipode
Thanks @Hemipode (+1) - the idea is that an automated process would kick off the build via Bamboo's REST API, passing in the value of the <ENV> param as a part of that RESTful call.Priscillaprise
H
8

This seems to be a work around but I believe it can help resolve your issue. Atlassian has a free plugin call Bamboo Inject Variables Plugin. Basically, with this plugin, you can create an "Inject Bamboo Variables from file" task to read a variable from a file.

So the idea here is to have your script set the variable to a specific file then kick off the build; the build itself will read that variable from the file and use it in the grails task.

UPDATE

After a search, I found that you can use REST API to change plan variables (NOT global). This would make your task simpler: just define a plan variable (in Plan Configuration -> tab Variables) then change it every time you need to. The information on how to change is available at Bamboo Knowledge Base

Hemipode answered 9/5, 2014 at 14:59 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.