Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
1.4k views
in Technique[技术] by (71.8m points)

Bamboo specific Build Plan Variable accessable in Karate

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?


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

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".


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

2.1m questions

2.1m answers

60 comments

57.0k users

...