将 cucumber.options(标签)作为环境变量传递到 Docker 容器中

huangapple go评论64阅读模式
英文:

Transfer cucumber.options (tags) as ENV into Docker container

问题

Here's the translated portion of the text:

大家好。

我有一个简单的基于Java的Cucumber应用程序,运行在Docker中。我计划使用Cucumber标签的环境变量来指定要运行哪些场景。

我的Dockerfile可以运行指定的标签:

FROM maven:3.6.1-jdk-11
COPY target/cucumber-app.jar ./

CMD java -jar -Dcucumber.options='--tags @default' cucumber-app.jar

在这种情况下,在运行docker run命令时一切都正常。

我计划为未指定标签设置一个默认场景,并通过环境变量设置特殊场景的能力:

FROM maven:3.6.1-jdk-11
COPY target/cucumber-app.jar ./
ENV TAG '--tags @default'

CMD java -jar -Dcucumber.options=$TAG cucumber-app.jar

不幸的是,在这种情况下,在运行docker容器后,我得到了以下错误:

Error: could not open 'default'

可能你有任何关于为什么使用环境变量会导致无法指定cucumber.options的想法吗?

英文:

Good day everyone.

I have a simple java-based cucumber application, that runs in Docker. I planing to specify which scenarios to run by using ENV for Cucumber tags.

My Dockerfile that able to run specified tags:

FROM maven:3.6.1-jdk-11
COPY target/cucumber-app.jar ./

CMD java -jar -Dcucumber.options='--tags @default' cucumber-app.jar

In this case, during docker run command all works perfectly.

I plan to set up a default scenario for not specified Tags and ability to set up special scenarios through ENV:

    FROM maven:3.6.1-jdk-11
    COPY target/cucumber-app.jar ./
    ENV TAG '--tags @default'
    
    CMD java -jar -Dcucumber.options=$TAG cucumber-app.jar

Unfortunately in this case after running docker container I got:

Error: could not open `default'

Possible you have any ideas why using ENV crash possibility to specify cucumber.options?

答案1

得分: 0

如果您使用的是较新版本的Cucumber,而不是尝试通过系统属性通过环境变量来传递命令行选项,您可以直接设置环境变量。例如:

ENV CUCUMBER_FILTER_TAGS '@Cucumber and not (@Gherkin or @Zucchini)'
CMD java -jar cucumber-app.jar

https://github.com/cucumber/cucumber-jvm/tree/main/core

英文:

If you have a recent version of Cucumber rather then trying to squeeze command line options in through a system property via an environment variable, you can set the environment variable straight away. I.e:

ENV CUCUMBER_FILTER_TAGS '@Cucumber and not (@Gherkin or @Zucchini)'
CMD java -jar cucumber-app.jar

https://github.com/cucumber/cucumber-jvm/tree/main/core

huangapple
  • 本文由 发表于 2020年7月28日 00:16:32
  • 转载请务必保留本文链接:https://go.coder-hub.com/63119290.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定