简体   繁体   English

使用Cucumber-JVM使用参数进行Jenkins构建

[英]Jenkins Build with Parameters using Cucumber-JVM

I was wondering if anyone here has ever used Jenkins with Cucumber-JVM and built their project using Build with Parameters plugin. 我想知道这里是否有人将Jenkins与Cucumber-JVM结合使用,并使用带有参数的构建插件构建了他们的项目。 Is it possible to pass parameters along to the steps definitions through Jenkins using the Build with Parameters plugin? 是否可以使用Build with Parameters插件通过Jenkins将参数传递给步骤定义?

EDIT 编辑

Ok, with Cucumber you have a feature file where you can have a data table when using a Scenario Outline with Examples. 好的,有了Cucumber,您就有了一个功能文件,当将带有示例的方案大纲使用时,您可以有一个数据表。 That data gets passed to the placeholder which then gets passed to your parameterized method. 该数据将传递到占位符,然后该占位符将传递给您的参数化方法。 I'm trying to understand how I would go about coding this with Jenkins or if it's even possible. 我试图了解如何使用Jenkins进行编码,或者甚至有可能。

I haven't heard of people changing data on scenario outlines through Jenkins parameters but I haven't tried to either. 我还没有听说有人通过Jenkins参数更改场景概要上的数据,但我也没有尝试过。 You would need Jenkins to act as a macro pre-processor to make all the substitutions. 您将需要詹金斯(Jenkins)充当宏预处理程序来进行所有替换。 And it sounds like you would need a lot of parameters. 听起来您需要很多参数。

A different approach may be to use Java properties files. 另一种方法可能是使用Java 属性文件。 Your java code can read the properties files and fill in objects that your steps then run with. 您的Java代码可以读取属性文件,并填充您要运行的对象。 Scenario outline data tables can be used to create List and Map objects (see here ). 方案大纲数据表可用于创建List和Map对象(请参见此处 )。 Instead of specifying the data in scenario outline tables, have the step read a properties file to populate the objects. 代替在方案大纲表中指定数据,而是让该步骤读取属性文件以填充对象。 Different property files can be deployed into different environments. 可以将不同的属性文件部署到不同的环境中。

This assumes that you really need this kind of flexibility which static cucumber doesn't provide. 假设您确实需要静态黄瓜无法提供的这种灵活性。 A nice touch would be to print out what the scenario outline data tables would have looked like. 一个不错的选择是打印出方案概要数据表的外观。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM