IOS 记录使用Jenkins 一键提审开发包(Jenkins+fastlane+python)
第一部分:fastlane
Fastlane 的学习所看的网站 https://www.jianshu.com/p/5d836e89d9d1
Fastlane 官网 https://fastlane.tools/
发布到AppStore fastlane 设置
increment_build_number#编译版本号自增加
commit_version_bump(force: true,
xcodeproj: "./JLBOrganization.xcodeproj")
match(type: "appstore", readonly: true)
gym#编译
deliver(force: true,
skip_screenshots: true,#跳过截图
skip_metadata: false,#不跳过信息提交
automatic_release: false,
submit_for_review: true)#发布到AppStore
以下说一下比较重要的一些点(其他的信息创建新的版本都会自动的带过来)
1.版本信息修改
在fastlane 文件夹中的Deliverfile 中 添加
release_notes({
‘zh-Hans’ => "fix bugs” #中文的版本信息
})
https://docs.fastlane.tools/actions/appstore/ 这里有很多不同国家版本的信息设置
2.App提交后submission_information 的选择(也就是最后选择idfa 那一页的选择)
在fastlane 文件夹中的Deliverfile中添加
submission_information({
add_id_info_limits_tracking: true,# 本人XXX,在此确认此App…………...
add_id_info_serves_ads: false,#在App内投放广告
add_id_info_tracks_action: true,#标明此App中发生的操作来自先前投放的广告
add_id_info_tracks_install: true,#标明此App安装来自先前投放的特定广告
add_id_info_uses_idfa: true,#App中是否使用广告标识符(idfa)
export_compliance_available_on_french_store: "false”,
export_compliance_contains_proprietary_cryptography: "false”,
export_compliance_contains_third_party_cryptography: "false”,
export_compliance_is_exempt: "false”,
export_compliance_uses_encryption: "false”,
export_compliance_app_type: nil,
export_compliance_encryption_updated: "false”,
export_compliance_compliance_required: "false”,
export_compliance_platform: "ios”,
content_rights_contains_third_party_content: "false”,
content_rights_has_rights: "false",
})
在以上设置中主要的设置还是idfa 其他的基本上都填false,如果有特殊需要可以去fastlane 官网查一下具体解释。
第二部分 python(3.7.X)
关于我这里为什么用Python做一下解释,通常我们做小版本的升级的时候,除了提审的ipa 包和版本信息需要修改,其他信息是不需要改的。(如果你们公司每个版本都换的话你其实可以不用考虑用这个方法了)我这里用Python时修改修改文件Deliverfile 内容中的 release_notes 各个版本信息。
关于Python的使用大家可以参考一下链接 https://blog.****.net/sky_long_fly/article/details/81705412
以下是我自己写的Python 修改代码。(注意 :Python版本 )
import subprocess
import os
import sys
# 输出高亮
def JLBPrint(message):
print('\033[1;31;40m' + message + '\033[0m')
# 终端跑命令 返回结果code
def JLBTerminalRun(terminalString):
return subprocess.run(terminalString, shell=True).returncode == 0
# git命令
class JLBGit:
def add(self):
return JLBTerminalRun('git add .')
def commit(self):
commitMessage = "修改fastlane版本信息文件"
return JLBTerminalRun('git commit -m \"' + commitMessage + '\"')
def push(self): # 提交先用master 分支
return JLBTerminalRun('git push origin master')
def pull(self): # 从主分支拉取代码
return JLBTerminalRun('git pull origin master')
def tag(self, version):
return JLBTerminalRun('git tag ' + version)
def deleteTag( self , version):
return JLBTerminalRun('git tag -d '+ version)
def pushTags(self):
return JLBTerminalRun('git push origin --tags')
class JLBChangeVersionInfo:
deliverfilePath = 'fastlane/Deliverfile'
def __init__(self, newVersionInfo):
self.newVersionInfo = newVersionInfo
def changeVersionInfo(self):
changResult = 0
fileRead = open (self.deliverfilePath, "r" )
for line in fileRead.readlines ():
strZH = ' \'zh-Hans\' => \"'
if line.find(strZH) >= 0:
changeLineStr = line.replace(strZH,'')
changeLineStr = changeLineStr[0:-2]
newLine = line.replace(changeLineStr,self.newVersionInfo)
fileWrite = open ( self.deliverfilePath, "r+" )
content = fileWrite.read ()
content = content.replace ( line, newLine )
fileWrite.seek ( 0 )
fileWrite.write ( content )
fileWrite.close ()
break
fileRead.close ()
return changResult
def main():
newVersionInfo = sys.argv[1] #获取终端第一个参数
git = JLBGit()
if git.pull():
# 创建修改版本信息
change = JLBChangeVersionInfo ( newVersionInfo )
# 修改版本信息
change.changeVersionInfo ()
if git.add():
if git.commit():
if git.push() == False:
JLBPrint('git push fail')
else:
JLBPrint('git commit fail')
else:
JLBPrint('git add fail')
else:
JLBPrint('pull fail')
if __name__ == '__main__':
main()
第三部分 Jenkins
关于Jenkins的部署大家可以看这里
https://www.jianshu.com/p/9dc3b45fbbec
在Jenkins 上部署打包环境,以下是我们公司的Jenkins 打包操作
打包操作
1)修改配置在打包任务中找到点击配置 找到以下图片位置。
2)上图中画圈的位子是 版本更新内容(注意:每个版本提交审核的时候,要修改审核的版本信息。就是下图位子内容),在配置中修改版本信息,然后保存修改内容(内容修改要注意 换行要用 “\n “ 如上图,内容中不要用 单引号 和双引号 ,如果一定要用请联系开发人员)。
3)执行此任务。(整个任务大概要15分钟左右,其时间随着网络、苹果服务器等因素影响)
关于报错信息
1.AppStore 网站账号登录过期。(有可能会经常出现此问题)解决办法:打开打包的机器,在此机器上登录一下账号,过程中有可能会要账号二次验证。请找运维或者IOS 开发人员验证登录后继续Jenkins 任务操作。
2.其他报错信息。(直接找开发人员看日志信息处理)
如果有不懂的欢迎留言!!!!!!!!