Welcome to OGeek Q&A 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 Reply

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


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...