1

How can you reference a Bamboo Build Plan variable inside a Karate config file? I have a Bamboo build plan for all of my karate tests. I need to be able to reference bamboo variables in the karate.config file for when the karate tests run though the bamboo build.

I've tried stuff like:

config.branchSource = karate.properties['branch.source'];

Where 'branch.source' is the bamboo build plan variable I enter at run time (Run Customized) with no luck.

I'm looking to pass a variable, that I input in bamboo, at runtime, where the karate tests will pickup and use appropriately. This other question, Using environment variables in Karate DSL testing, doesn't work. It speaks about java system properties. I'm not looking for system properties, I'm looking for Bamboo Build Plan Variables. Any ideas?

Corey Snow
  • 225
  • 2
  • 15

1 Answers1

1

You have to add them to the command line, in my case, to the maven command.

IE. If we add this "-Dbamboo_build_variable=”whatever was entered” " to the "clean test" command, then the variable bamoo_build_variable will be accessible by Karate.
So in Karate.config you can read it, like this "var bamooVariable = bamboo_build_variable".

Corey Snow
  • 225
  • 2
  • 15
  • not sure if that's accurate - but those who come across this answer in future, please refer: https://stackoverflow.com/a/52821230/143475 – Peter Thomas Jan 20 '21 at 15:39