You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

Fastlane CLI传入参数被截断:PR标题参数传递异常

问题

我尝试把Pull Request(PR)标题作为参数传给Fastlane的distribute lane,执行命令:

fastlane android distribute release_notes:$PR_TITLE

从日志里能看到命令携带了完整标题:

[16:37:52]: $ bundle exec fastlane android distribute release_notes:ref: copy the services module inside app module

但在lane代码里打印传入的参数时,发现参数被截断,只输出release_notes ref:;而且如果标题里有换行符,也会导致参数异常截断。对应的lane代码如下:

desc "distribute new build for testers, set internal to true to pass it for internal testrs"
lane :distribute do |options|
    print "\n"
    print "release_notes"

    print options[:release_notes]
解决办法

问题根源是shell会把PR标题里的空格、冒号这类字符当作参数分隔符,导致Fastlane只能接收到第一个分隔符前的内容。给两个靠谱的解决方式:

  • 方式1:用引号包裹参数
    执行命令时,把$PR_TITLE用双引号括起来,让shell把整个标题当成一个完整参数传递:

    fastlane android distribute release_notes:"$PR_TITLE"
    

    不管标题里有空格、冒号还是换行符,都能完整传给Fastlane。

  • 方式2:通过环境变量传递(更适配特殊字符场景)
    如果PR标题里包含引号这类更特殊的字符,用环境变量更稳妥:

    1. 先设置环境变量:
      export PR_TITLE="$PR_TITLE"
      
    2. 修改lane代码,直接读取环境变量:
      desc "distribute new build for testers, set internal to true to pass it for internal testrs"
      lane :distribute do |options|
          print "\n"
          print "release_notes: "
          print ENV['PR_TITLE']
      end
      

    执行命令时不用传release_notes参数,直接运行:

    fastlane android distribute
    

内容的提问来源于stack exchange,提问作者David Ibrahim

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.08.07 12:55:18