如何从 CLI 输出中捕获
testing_uri
,如 Firebase 应用程序分发的文档中所述。 test_uri 是否作为环境变量公开,或者我应该使用一些自定义正则表达式解析输出并获取 uri
这是我从 CLI 命令得到的输出
firebase appdistribution:distribute
出于隐私原因删除特定的 uri,但这是输出格式,没有像
testing_uri
这样的变量
我想在“与有权访问的测试人员共享此版本:”之后获取 uri:
View this release in the Firebase console: https://console.firebase.google.com/project.....
Share this release with testers who have access: https://appdistribution.firebase.google.com/testerapps/.....
Download the release binary (link expires in 1 hour): uri....
testing_uri
不会作为 firebase 应用程序分发的环境变量公开。就像您提到的,您需要使用 regex
解析输出以获得所需的 uri。我可以帮助编写一个 bash 脚本,该脚本将执行 firebase appdistribution:distribute
并将 testing_uri
导出到环境变量。
#!/bin/bash
# Run the Firebase App Distribution command
output=$(firebase appdistribution:distribute <your-app-path> --app <your-app-id> --token <your-token>)
# Use regex to find the testing URI in the output
uri=$(echo "$output" | grep -oE "https://appdistribution\.firebase\.google\.com/testerapps/[a-zA-Z0-9]+")
# Check if the URI pattern as described above was matched
if [ -n "$uri" ]; then
echo "Testing URI found: $uri"
# Export the URI as an environment variable
export TESTING_URI="$uri"
echo "TESTING_URI is now set as an environment variable"
else
echo "Testing URI not found in the output"
fi
保存上面的 bash 脚本,并使用您选择的以
.sh
结尾的名称。
你可以命名它get_firebase_testing_uri.sh
。
使用以下命令使脚本可执行:
chmod +x get_firebase_testing_uri.sh
使用以下命令运行 bash 脚本:
./get_firebase_testing_uri.sh
通过echo获取导出的环境变量如下图:
echo $TESTING_URI
我希望这有效!