如何在 String 类型的 fastlane 选项变量上使用 Java String 属性 contains/startsWith

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

下面是我的代码,我需要检查变量是否以“QA_”开头,谢谢您的提前赞赏。

   desc "CREATE BUILD BY TAG"
   lane :createBuildByTag do |options|
       env = options[:env]
       # if env == "QA_0.0"
       # contains not working for below line
       if options[:env].contains("QA_")
            gradle(task: "clean assemblePreStageDebug")
            upload_drive(options)
       end
   end


   #  Note- I am calling above method by below command
   - name: upload driveStageAPK to Google Drive
     run: bundle exec fastlane createBuildByTag env:"${{ github.ref_name }}"   
     #QA_9.9.1 
android yaml github-actions cicd fastlane
1个回答
0
投票

您是在 Fastfile 中编写 Ruby 代码还是使用 Java 来检查字符串匹配的模式?

如果是前者,您要查找的函数是 include()

那么,

`...

 if env && env.include?("QA_")
    #rest of code
 ...
`
© www.soinside.com 2019 - 2024. All rights reserved.