Fastlane和shell脚本。是18而不是0

问题描述 投票:0回答:1

我试图用.ipajenkins卷曲fastlane,但我的脚本失败了:

'chmod +x ./publish.sh; ./publish.sh;' was 18 instead of 0. (FastlaneCore::Interface::FastlaneShellError)
Uploading: ./../MobileApp.ipa

在我的Fastfile

sh('chmod +x ./publish.sh; ./publish.sh;')

这是我的脚本的内容:

#!/bin/bash -e

upload() {
  for file in ./../*.ipa; do
    echo "Uploading: $file"
  response=$(
    curl -u $PUBLISH_USER:$PUBLISH_PASS -T $file http://example.com/ios-dev-local/ \
        --write-out %{http_code} \
        --silent \
        --output /dev/null \
  )
  done
}

upload;

if [ "$response" -gt 400 ];
then
  echo "bounce with status $response"
  exit 1;
fi;

这是完整的堆栈跟踪:

from /Users/myUser/.fastlane/bin/bundle/lib/ruby/gems/2.2.0/gems/fastlane-2.69.2/fastlane_core/lib/fastlane_core/ui/ui.rb:14:in `method_missing'
from /Users/myUser/.fastlane/bin/bundle/lib/ruby/gems/2.2.0/gems/fastlane-2.69.2/fastlane/lib/fastlane/helper/sh_helper.rb:75:in `sh_control_output'
from /Users/myUser/.fastlane/bin/bundle/lib/ruby/gems/2.2.0/gems/fastlane-2.69.2/fastlane/lib/fastlane/helper/sh_helper.rb:16:in `sh_no_action'
from /Users/myUser/.fastlane/bin/bundle/lib/ruby/gems/2.2.0/gems/fastlane-2.69.2/fastlane/lib/fastlane/fast_file.rb:184:in `block in sh'
from /Users/myUser/.fastlane/bin/bundle/lib/ruby/gems/2.2.0/gems/fastlane-2.69.2/fastlane/lib/fastlane/actions/actions_helper.rb:50:in `execute_action'
from /Users/myUser/.fastlane/bin/bundle/lib/ruby/gems/2.2.0/gems/fastlane-2.69.2/fastlane/lib/fastlane/fast_file.rb:183:in `sh'
from /Users/myUser/.fastlane/bin/bundle/lib/ruby/gems/2.2.0/gems/fastlane-2.69.2/fastlane/lib/fastlane/fast_file.rb:178:in `sh'
from Fastfile:68:in `block (2 levels) in parsing_binding'
from /Users/myUser/.fastlane/bin/bundle/lib/ruby/gems/2.2.0/gems/fastlane-2.69.2/fastlane/lib/fastlane/lane.rb:33:in `call'
from /Users/myUser/.fastlane/bin/bundle/lib/ruby/gems/2.2.0/gems/fastlane-2.69.2/fastlane/lib/fastlane/lane.rb:33:in `call'
from /Users/myUser/.fastlane/bin/bundle/lib/ruby/gems/2.2.0/gems/fastlane-2.69.2/fastlane/lib/fastlane/runner.rb:49:in `block in execute'
from /Users/myUser/.fastlane/bin/bundle/lib/ruby/gems/2.2.0/gems/fastlane-2.69.2/fastlane/lib/fastlane/runner.rb:45:in `chdir'
from /Users/myUser/.fastlane/bin/bundle/lib/ruby/gems/2.2.0/gems/fastlane-2.69.2/fastlane/lib/fastlane/runner.rb:45:in `execute'
from /Users/myUser/.fastlane/bin/bundle/lib/ruby/gems/2.2.0/gems/fastlane-2.69.2/fastlane/lib/fastlane/lane_manager.rb:56:in `cruise_lane'
from /Users/myUser/.fastlane/bin/bundle/lib/ruby/gems/2.2.0/gems/fastlane-2.69.2/fastlane/lib/fastlane/command_line_handler.rb:34:in `handle'
from /Users/myUser/.fastlane/bin/bundle/lib/ruby/gems/2.2.0/gems/fastlane-2.69.2/fastlane/lib/fastlane/commands_generator.rb:104:in `block (2 levels) in run'
from /Users/myUser/.fastlane/bin/bundle/lib/ruby/gems/2.2.0/gems/commander-fastlane-4.4.5/lib/commander/command.rb:178:in `call'
from /Users/myUser/.fastlane/bin/bundle/lib/ruby/gems/2.2.0/gems/commander-fastlane-4.4.5/lib/commander/command.rb:178:in `call'
from /Users/myUser/.fastlane/bin/bundle/lib/ruby/gems/2.2.0/gems/commander-fastlane-4.4.5/lib/commander/command.rb:153:in `run'
from /Users/myUser/.fastlane/bin/bundle/lib/ruby/gems/2.2.0/gems/commander-fastlane-4.4.5/lib/commander/runner.rb:476:in `run_active_command'
from /Users/myUser/.fastlane/bin/bundle/lib/ruby/gems/2.2.0/gems/fastlane-2.69.2/fastlane_core/lib/fastlane_core/ui/fastlane_runner.rb:66:in `run!'
from /Users/myUser/.fastlane/bin/bundle/lib/ruby/gems/2.2.0/gems/commander-fastlane-4.4.5/lib/commander/delegates.rb:15:in `run!'
from /Users/myUser/.fastlane/bin/bundle/lib/ruby/gems/2.2.0/gems/fastlane-2.69.2/fastlane/lib/fastlane/commands_generator.rb:343:in `run'
from /Users/myUser/.fastlane/bin/bundle/lib/ruby/gems/2.2.0/gems/fastlane-2.69.2/fastlane/lib/fastlane/commands_generator.rb:42:in `start'
from /Users/myUser/.fastlane/bin/bundle/lib/ruby/gems/2.2.0/gems/fastlane-2.69.2/fastlane/lib/fastlane/cli_tools_distributor.rb:75:in `take_off'
from /Users/myUser/.fastlane/bin/bundle/lib/ruby/gems/2.2.0/gems/fastlane-2.69.2/bin/fastlane:20:in `<top (required)>'
from /Users/myUser/.fastlane/bin/bundle/bin/fastlane:22:in `load'
from /Users/myUser/.fastlane/bin/bundle/bin/fastlane:22:in `<main>'
Build step 'Execute shell' marked build as failure

有人可以向我解释一下我收到的18个错误代码是什么以及它为什么会发生?

jenkins sh fastlane
1个回答
1
投票

这是该命令行中某些内容的返回值。我假设您已经尝试手动执行完全没问题。通常当shell命令出现故障时,您会在该错误之前获得shell输出。是否有任何关于它失败的原因?您是否尝试过chmod +x ./publish.sh && ./publish.sh以确保它不会尝试执行脚本,除非chmod成功?

如果这些都没有帮助,我建议尝试这样的事情进一步调查:

sh "chmod", "+x", "./publish.sh" do |status, output, command|
  unless status.success?
    UI.user_error! "#{command} failed with status #{status.exitstatus}. Output was #{output}"
  end

  sh "./publish.sh" do |status, output, command|
    unless status.success?
      UI.user_error! "#{command} failed with status #{status.exitstatus}. Output was #{output}"
    end
  end
end

这只是为了帮助您了解失败的原因以及sh错误处理的工作原理。我认为命令的输出应该显示错误。如果没有这些变化,您可能已经拥有它。

此外,更多关于shhttps://docs.fastlane.tools/advanced/#using-the-sh-method

更新

我怀疑curl正在返回18.来自curl手册页:

18     Partial file. Only a part of the file was transferred.

并且你没有在curl的输出中看到它,因为你的shell脚本正在吞咽输出。您可能需要在循环中修改脚本以执行以下操作:

if [[ $? != 0 ]]; then echo $response; fi
© www.soinside.com 2019 - 2024. All rights reserved.