Jenkins和fastlane的使用日志

191 阅读1分钟

fastlane

使用ruby语言

 lane :devapp do 
    content = `git log -5 --pretty --oneline --no-merges`
    message = content
    puts content
   
    time = Time.new.strftime("%y%m%d%H%M") #获取时间格式
    version = get_version_number#获取版本号
    ipaName = "DEV_#{version}_#{time}.ipa"
    build_no = "#{time}"

    gym(
       scheme:"AIOffice", #项目名称
       export_method:"enterprise",#打包的类型
       configuration:"Debug",#模式,默认Release,还有Debug,Uat。注意Uat需要自己多配置一个configuration
       output_name:"#{ipaName}",#输出的包名
       output_directory:"./build",#输出的位置
       export_xcargs: "allowProvisioningUpdates",
       skip_profile_detection: true,
       export_options: {
          method:"enterprise",
          signingCertificate:"iOS Distribution",
          provisioningProfiles: {
             "com.xxxxx.123"=>"Distribution-xxxxx-123"
           }
       }
     )

    increment_build_number(
         build_number: build_no,
    )
    pgyer( #蒲公英上传
          api_key: "xxxxxxxx138139817938",
         password: "123456",
         update_description: "DEV: #{message}", #更新版本信息,这里用近5条git提交的信息
         channel: "abc" #上传渠道
    )
  end

Jenkins

Jenkins服务我是使用jenkins-lts,所以重启之类是: brew services restart jenkins-lts 网上有brew services restart jenkins

构建方式

我使用的是走脚本shell的方式

#!/bin/bash
export LANG=en_US.UTF-8
cd /(你的项目)
git reset --hard HEAD
git commit --allow-empty-message
git pull origin 分支名
cd /(你的项目)
fastlane devapp

这里看个人情况而定,这里我是自己加了代码拉取

局域网无法访问处理

本人使用的是M1的系统,所以修改的是两个地方

/Users/(你的用户名)/Library/LaunchAgents/homebrew.mxcl.jenkins-lts.plist /opt/homebrew/Cellar/jenkins-lts/2.387.1/homebrew.mxcl.jenkins-lts.plist

把里面的 httpListenAddress = 127.0.0.1改为0.0.0.0,然后重启一下服务就OK了。