运行 cron 作业时执行 fastlane 命令丢失 Gem

Execute Fastlane Command missing Gem when operating cron job

当我进入 Mac 终端并执行包含以下命令集的 sh 文件时,它运行顺利。当我允许我的裁剪选项卡在上午 9 点到晚上 18 点之间执行每个小时时,它会显示以下异常

Fetching origin
hint: Pulling without specifying how to reconcile divergent branches is
hint: discouraged. You can squelch this message by running one of the following
hint: commands sometime before your next pull:
hint: 
hint:   git config pull.rebase false  # merge (the default strategy)
hint:   git config pull.rebase true   # rebase
hint:   git config pull.ff only       # fast-forward only
hint: 
hint: You can replace "git config" with "git config --global" to set a default
hint: preference for all repositories. You can also pass --rebase, --no-rebase,
hint: or --ff-only on the command line to override the configured default per
hint: invocation.
Already up to date.
Already on 'feature/sprint_1'
M   src/Podfile.lock
M   src/MyProject/Info.plist
Your branch is up to date with 'origin/feature/sprint_7'.
bundler: command not found: fastlane
Install missing gem executables with `bundle install`

在我的项目文件夹结构中,GemfileGemfile.lock 存在。我需要..

  1. 在执行我的命令集之前修改 Gemfile?
  2. 使用超级用户 sudo 访问权限执行我的命令?
  3. 如果 bundle 和 fastlane 已正确安装,我如何确认要执行的文件路径是否正确?

4.The 下面是我的 .sh 文件,其中包含以下命令集:我还需要修改我的命令集吗?

cd ~/myProject/src && git stash clear && git fetch --all && git pull && git checkout  && bundle exec fastlane ios build build_type:adhoc build_env:dev

其中 </code> 是我建议的分支,例如<code>master, release , feature/sprint_1

根据您日志的最后 3 行,它们是:

Your branch is up to date with 'origin/feature/sprint_7'.
bundler: command not found: fastlane
Install missing gem executables with `bundle install`

并且您的脚本开头有 cd 和 4 个 git 命令。我假设 $1 是主人。基本上是这样的:

cd ~/myProject/src 
git stash clear
git fetch --all
git pull 
git checkout master # or 
bundle exec fastlane ios build build_type:adhoc build_env:dev

Bundler 说 command not found: fastlane 然后它显示了您需要 运行 bundle install.

的解决方案

可能当您在 bundle exec 之前添加 bundle install 时您会解决您的问题:

cd ~/myProject/src 
git stash clear
git fetch --all
git pull 
git checkout master # or 
bundle install
bundle exec fastlane ios build build_type:adhoc build_env:dev