如何使用 gcloud cli for Firebase Test Lab 在 yaml arg 文件中设置环境变量
How to set up environment variables in yaml arg-file with gcloud cli for Firebase Test Lab
用于在 Firebase 测试实验室上启动仪器测试的 gcloud 命令工作正常:
gcloud firebase test android run \
--type instrumentation \
--app app/build/outputs/apk/demo/debug/app-demo-debug.apk
--test app/build/outputs/apk/androidTest/demo/debug/app-demo-debug-androidTest.apk \
--device model=Nexus6,version=21,locale=en,orientation=portrait
--environment-variables cucumberOptions="--tags '@demo and @e2e'"
但是,当我尝试将参数提取到 arg-spec yaml 文件中时,我在定义环境变量时遇到了问题:
gcloud firebase test android run firebase/testlab/tests.yaml:demo-cucumber-E2E-test
firebase/testlab/tests.yaml:
demo-cucumber-E2E-test:
type: instrumentation
app: app/build/outputs/apk/demo/debug/app-demo-debug.apk
test: app/build/outputs/apk/androidTest/demo/debug/app-demo-debug-androidTest.apk
device: [{model: Nexus6, version: 21, locale: en, orientation: portrait}]
environment-variables: [{cucumberOptions="--tags '@demo and @e2e'"}]
我收到以下错误:
ERROR: (gcloud.firebase.test.android.run) Invalid value for
[environment-variables]: Malformed key-value pairs.
如何在 arg-spec yaml 文件中正确定义环境变量?
我不知道为什么编码到数组中不起作用,但您可以通过以下方式格式化 yaml 文件使其起作用:
demo-cucumber-E2E-test:
type: instrumentation
app: app/build/outputs/apk/demo/debug/app-demo-debug.apk
test: app/build/outputs/apk/androidTest/demo/debug/app-demo-debug-androidTest.apk
device:
- model: Nexus6
version: 21
locale: 'en'
orientation: portrait
environment-variables:
cucumberOptions: "--tags '@demo and @e2e'"
编辑
我明白了为什么您最初的示例不起作用。它需要 2 处更改:
- 将
=
替换为:
- 删除数组
[]
for environment-variables
demo-cucumber-E2E-test:
type: instrumentation
app: app/build/outputs/apk/demo/debug/app-demo-debug.apk
test: app/build/outputs/apk/androidTest/demo/debug/app-demo-debug-androidTest.apk
device: [{model: Nexus6, version: 21, locale: en, orientation: portrait}]
environment-variables: {cucumberOptions: "--tags '@demo and @e2e'"}
用于在 Firebase 测试实验室上启动仪器测试的 gcloud 命令工作正常:
gcloud firebase test android run \
--type instrumentation \
--app app/build/outputs/apk/demo/debug/app-demo-debug.apk
--test app/build/outputs/apk/androidTest/demo/debug/app-demo-debug-androidTest.apk \
--device model=Nexus6,version=21,locale=en,orientation=portrait
--environment-variables cucumberOptions="--tags '@demo and @e2e'"
但是,当我尝试将参数提取到 arg-spec yaml 文件中时,我在定义环境变量时遇到了问题:
gcloud firebase test android run firebase/testlab/tests.yaml:demo-cucumber-E2E-test
firebase/testlab/tests.yaml:
demo-cucumber-E2E-test:
type: instrumentation
app: app/build/outputs/apk/demo/debug/app-demo-debug.apk
test: app/build/outputs/apk/androidTest/demo/debug/app-demo-debug-androidTest.apk
device: [{model: Nexus6, version: 21, locale: en, orientation: portrait}]
environment-variables: [{cucumberOptions="--tags '@demo and @e2e'"}]
我收到以下错误:
ERROR: (gcloud.firebase.test.android.run) Invalid value for [environment-variables]: Malformed key-value pairs.
如何在 arg-spec yaml 文件中正确定义环境变量?
我不知道为什么编码到数组中不起作用,但您可以通过以下方式格式化 yaml 文件使其起作用:
demo-cucumber-E2E-test:
type: instrumentation
app: app/build/outputs/apk/demo/debug/app-demo-debug.apk
test: app/build/outputs/apk/androidTest/demo/debug/app-demo-debug-androidTest.apk
device:
- model: Nexus6
version: 21
locale: 'en'
orientation: portrait
environment-variables:
cucumberOptions: "--tags '@demo and @e2e'"
编辑
我明白了为什么您最初的示例不起作用。它需要 2 处更改:
- 将
=
替换为:
- 删除数组
[]
forenvironment-variables
demo-cucumber-E2E-test:
type: instrumentation
app: app/build/outputs/apk/demo/debug/app-demo-debug.apk
test: app/build/outputs/apk/androidTest/demo/debug/app-demo-debug-androidTest.apk
device: [{model: Nexus6, version: 21, locale: en, orientation: portrait}]
environment-variables: {cucumberOptions: "--tags '@demo and @e2e'"}