如何将gitlab-ci变量传递给空手道罐子? [英] How do I pass gitlab-ci variables to karate Netty jar?

查看:366
本文介绍了如何将gitlab-ci变量传递给空手道罐子?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试在gitlab-ci管道中使用Karate Netty jar.我正在提取一个包含jar的图像,作为管道中的步骤.我能够针对不安全的服务执行测试. 像这样:

I'm trying to use Karate Netty jar in a gitlab-ci pipeline. I'm pulling in an image that contains the jar as a step in the pipeline. I am able to execute tests just fine for unsecured services. Like so:

karate-test:
    stage: acceptance-test
    image:
        name: registry.gitlab.opr.business.org/karate-universe:0.0.3
        entrypoint: [ "" ]
    script:
        - java -jar /karate.jar -e dev src/test/karate/acceptance-test.feature -o /target/karate
    environment:
        name: Test
    artifacts:
        paths:
            - /target/karate

现在,我正在尝试将凭据传递到用于安全服务的空手道功能中,但无法从jar界面中找到功能.

Now I'm trying to pass credentials into a karate feature for a secured service but cannot find the capabilities from the jar interface.

我尝试像这样传递凭据:

I've tried passing the credentials like so:

    - java -jar /karate.jar -e dev src/test/karate/acceptance-test.feature -o /target/karate -Duser.password ${REQUEST_PASSWORD} -Duser.id ${REQUEST_USER}

REQUEST_PASSWORD和REQUEST_USER是gitlab变量中可供我使用的gitlab变量.

REQUEST_PASSWORD and REQUEST_USER are gitlab variables that are available to me in gitlab-ci.

运行管道时,我得到:

Unmatched arguments [-Duser.password, -Duser.id]

空手道Netty是否具有像常规空手道一样能够传递用于空手道配置的变量的功能?我不能在karate-config文件本身中保留秘密.

Does Karate Netty have the capabilities of being able to pass variables for karate-config use like regular Karate does? I cannot keep secrets in the karate-config file itself.

推荐答案

确保-Dfoo=bar部分位于之前 -jar选项,因为此后的所有内容都传递给了空手道,并且不是 JVM.

Make sure the -Dfoo=bar part comes before the -jar option, because everything after that is passed to Karate, and not the JVM.

java -Dfoo=bar -Dbaz=ban -jar /karate.jar

请注意,您还可以轻松获得环境变量:

Note that you can also get environment variables easily:

java.lang.System.getenv('PATH')

通常,人们将值作为-D JVM选项传递.如果您对独立JAR有一些高级需求-请参阅: https://stackoverflow.com/a/56458094/143475

Normally people pass values as -D JVM options. If you have some advanced needs for the standalone JAR - see this: https://stackoverflow.com/a/56458094/143475

这篇关于如何将gitlab-ci变量传递给空手道罐子?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆