i am new for Jenkins and want to pass a parameter like cucumber tag from jenkins and it should update in test runner file dynamically and then should start execution. Please share me code or screenshots.
Asked
Active
Viewed 9,506 times
3
-
What kind of project you are working on? For example, Freestyle or Pipeline – UnknownBeast Jun 12 '20 at 17:15
-
its maven project. – vishalbha Jun 13 '20 at 10:47
2 Answers
5
In addition to UnknownBeast, with Cucumber v6 and onwards you can no longer use cucumber.options
with a command line like string. Instead you'll have to use individual properties.
mvn test -Dcucumber.filter.tags="(@cucumber or @gherkin) and not @salad"
Supported properties are:
cucumber.ansi-colors.disabled= # true or false. default: false
cucumber.execution.dry-run= # true or false. default: false
cucumber.execution.limit= # number of scenarios to execute (CLI only).
cucumber.execution.order= # lexical, reverse, random or random:[seed] (CLI only). default: lexical
cucumber.execution.strict= # true or false. default: false.
cucumber.execution.wip= # true or false. default: false.
cucumber.features= # command separated paths to feature files. example: path/to/example.feature, path/to/other.feature
cucumber.filter.name= # regex. example: .*Hello.*
cucumber.filter.tags= # tag expression. example: @smoke and not @slow
cucumber.glue= # comma separated package names. example: com.example.glue
cucumber.plugin= # comma separated plugin strings. example: pretty, json:path/to/report.json
cucumber.object-factory= # object factory class name. example: com.example.MyObjectFactory
cucumber.snippet-type= # underscore or camelcase. default: underscore

M.P. Korstanje
- 10,426
- 3
- 36
- 58
-
Hello M.P. could you please let me where I can see the changelog? – UnknownBeast Jun 13 '20 at 02:41
-
Thanks @M.P. Korstanje for the replay, but my requirement is from jenkins in a label text box ill write tag name that will automatically add in shell script and while building a job dynamically pass tag name in test runner class to perfrom execution. Kindly share me with screenshot if you have this project. – vishalbha Jun 13 '20 at 11:00
1
If you want to run the test cases associated to Tags, this is how we specify : mvn test -Dcucumber.options=”–tags @tag Name”
So what you can do, set the parameters in the Jenkins job and then you can execute the test script with the above maven command. So the tag name will come from the parameter that you have set in the Jenkins job.

UnknownBeast
- 979
- 1
- 6
- 13
-
Thanks, @UnkinwnBeast, I want to pass cucumber parameter using a text box where user enters tag it refers shell script and before performing execution it has to update that tag in test runner file. – vishalbha Jun 13 '20 at 11:03
-
Here everything will be same in the runner file. When pass this parameter it overrides the configuration that you have added in the runner file. So I believe that you can do the execution of maven goals with the shell script too – UnknownBeast Jun 13 '20 at 11:43
-
@vishalbha did you manage to do what you need? I was also looking for this solution. – zephirus Jan 06 '22 at 12:24
-
I have entered `$ mvn test -Dcucumber.options=”–tags @smoketest”` and get error ``` [ERROR] Unknown lifecycle phase "@smoketest”". You must specify a valid lifecycle phase or a goal in the format
: – Leder Jun 13 '22 at 09:19or : [: ]: . Available lifecycle phases are: ... ```