Unity云构建bash脚本来修改文件,使用$WORKSPACE变量
我正在尝试创建一个仅在云构建目标的产品版本上运行的Shell脚本。它的目标是替换生产值的捆绑包ID和Firebase配置文件。我正在使用$ workspace环境变量使用bash实现一些基本文件操作。 It seems to be working fine for the android build, but it's erroring for the ios build.
Here's the simple script:
#!/bin/sh
echo $WORKSPACE
mv $WORKSPACE/client/Assets/google-services.json_prod $WORKSPACE/client/Assets/google-service.json
mv $WORKSPACE/client/Assets/GoogleService-Info.plist_prod $WORKSPACE/client/Assets/GoogleService-Info.plist
sed -i 's/Android: redacted/Android: redacted/g' $WORKSPACE/client/ProjectSettings/ProjectSettings.asset
sed -i 's/iPhone: redacted/iPhone: hredacted/g' $WORKSPACE/client/ProjectSettings/ProjectSettings.asset
sed -i 's/overrideDefaultApplicationIdentifier: 0/overrideDefaultApplicationIdentifier: 1/g' $WORKSPACE/client/ProjectSettings/ProjectSettings.asset
sed -i 's/productName: redacted: redacted/g' $WORKSPACE/client/ProjectSettings/ProjectSettings.asset
On ios build, here's the output:
Executing Pre-Build Script at Assets/Shell/pre_build.sh
73: /BUILD_PATH/unity_4b7b6722eef28df6b99d.baseball-rivalszk5qkewb
74: sed: orkspace/workspace/unity_4b7b6722eef28df6b99d.baseball-rivalszk5qkewb/client/ProjectSettings/ProjectSettings.asset: No such file or directory
75: sed: orkspace/workspace/unity_4b7b6722eef28df6b99d.baseball-rivalszk5qkewb/client/ProjectSettings/ProjectSettings.asset: No such file or directory
76: sed: orkspace/workspace/unity_4b7b6722eef28df6b99d.baseball-rivalszk5qkewb/client/ProjectSettings/ProjectSettings.asset: No such file or directory
77: sed: orkspace/workspace/unity_4b7b6722eef28df6b99d.baseball-rivalszk5qkewb/client/ProjectSettings/ProjectSettings.asset: No such file or directory
78: ! build of 'ios-prod' failed. Pre-Build script exited with status 1. Aborting.
I'm trying to create a shell script that runs only on the prod versions of the cloud build targets. Its goal is to replace the bundle id and firebase config files for the production values. I'm using the $WORKSPACE environment variable to achieve some basic file manipulation using bash. It seems to be working fine for the android build, but it's erroring for the ios build.
Here's the simple script:
#!/bin/sh
echo $WORKSPACE
mv $WORKSPACE/client/Assets/google-services.json_prod $WORKSPACE/client/Assets/google-service.json
mv $WORKSPACE/client/Assets/GoogleService-Info.plist_prod $WORKSPACE/client/Assets/GoogleService-Info.plist
sed -i 's/Android: redacted/Android: redacted/g' $WORKSPACE/client/ProjectSettings/ProjectSettings.asset
sed -i 's/iPhone: redacted/iPhone: hredacted/g' $WORKSPACE/client/ProjectSettings/ProjectSettings.asset
sed -i 's/overrideDefaultApplicationIdentifier: 0/overrideDefaultApplicationIdentifier: 1/g' $WORKSPACE/client/ProjectSettings/ProjectSettings.asset
sed -i 's/productName: redacted: redacted/g' $WORKSPACE/client/ProjectSettings/ProjectSettings.asset
On ios build, here's the output:
Executing Pre-Build Script at Assets/Shell/pre_build.sh
73: /BUILD_PATH/unity_4b7b6722eef28df6b99d.baseball-rivalszk5qkewb
74: sed: orkspace/workspace/unity_4b7b6722eef28df6b99d.baseball-rivalszk5qkewb/client/ProjectSettings/ProjectSettings.asset: No such file or directory
75: sed: orkspace/workspace/unity_4b7b6722eef28df6b99d.baseball-rivalszk5qkewb/client/ProjectSettings/ProjectSettings.asset: No such file or directory
76: sed: orkspace/workspace/unity_4b7b6722eef28df6b99d.baseball-rivalszk5qkewb/client/ProjectSettings/ProjectSettings.asset: No such file or directory
77: sed: orkspace/workspace/unity_4b7b6722eef28df6b99d.baseball-rivalszk5qkewb/client/ProjectSettings/ProjectSettings.asset: No such file or directory
78: ! build of 'ios-prod' failed. Pre-Build script exited with status 1. Aborting.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我最终从脚本中删除了$ workspace变量,并仅使用类似这样的相对路径:
./ client/assets ...
,它起作用。I ended up removing the $WORKSPACE variable from the script and using only a relative path like this:
./client/Assets...
and it worked.