TeamCity集成Maven Cucumber测试时的参数配置问题
Hey there, the problem you're facing is almost certainly caused by the extra outer quotes around -Dcucumber.options in your TeamCity build step parameters. Let me break this down and walk you through the fix:
Why the quotes break things
On your local terminal, you need those quotes around "-Dcucumber.options=--tags @test" to tell the shell to pass the entire --tags @test string as a single, unified value to Cucumber. But TeamCity’s parameter input box handles parameter separation automatically—adding those outer quotes makes TeamCity treat the quotes themselves as part of the parameter value, which Cucumber can’t parse correctly.
Correct TeamCity Configuration
Update your 附加Maven命令行参数 to this, removing the outer quotes around the Cucumber options:
-Pdev -Dserver=remote -Dbrowser=ie -Dcucumber.options=--tags @test
If you ever need to pass more complex Cucumber options (like multiple tags or glue paths with spaces), you only need quotes around the value part inside the -D parameter (not the entire -Dcucumber.options=... string). For example:
-Pdev -Dserver=remote -Dbrowser=ie -Dcucumber.options="--tags @test --glue com.example.steps"
Quick Verification Tip
After updating the configuration, run a test build and check the TeamCity build logs. Look for the actual Maven command being executed—it should exactly match the working command you use locally, with no extra stray quotes.
Bonus Troubleshooting Steps
If you still hit issues:
- Double-check that the TeamCity agent uses the same Maven version as your local machine (version mismatches can cause subtle parameter parsing differences)
- Verify there are no conflicting environment variables set on the agent that might override your
cucumber.optionsor other parameters
内容的提问来源于stack exchange,提问作者arena

