Search code examples
javadockercucumbercucumber-jvmcucumber-java

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


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?


Solution

  • 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