iOS

iOS使用Jenkins自动打包

2021-06-24  本文已影响0人  biggerworld

安装Jenkins

   brew install jenkins

然后运行jenkins,启动后访问localhost:8080, 如果访问正常说明安装成功了。
因为打包脚本使用的是python脚本,所以要在插件管理里面安装python插件。

使用Jenkins

# 在jenkins上使用的打包脚本

import optparse
import os
import sys
import getpass
import json
import time
import commands
import re
import string

targetName = 'package'
mainPath = os.environ['WORKSPACE']
branch = os.environ['branch']
version = ''
if os.environ.has_key('version'):
    version = os.environ['version']
    
print(branch,version)

cmd='cd "%s"; git reset --hard HEAD; git checkout %s; git pull'%(mainPath,branch)
print(cmd)
os.system(cmd)

cmd = 'cd "%s"; python build.py %s %s %s %s'%(mainPath,targetName,branch,os.environ['BUILD_ID'],version)
print(cmd)
os.system(cmd)
import optparse
import os
import sys
import getpass
import json
import time
import commands
import re
import string
import subprocess
import codecs
import shutil

print('执行build.py')
for item in sys.argv:
    print(item)

mainPath = os.path.split(os.path.realpath(__file__))[0]
print(mainPath)
mainPath = os.path.join(mainPath,'package')

cmd="cd %s;xcodebuild archive -workspace %s.xcworkspace -scheme %s -configuration 'Release Adhoc' -archivePath ./build -derivedDataPath ./derivedData"%(mainPath,'package','package')
print(cmd)
os.system(cmd)

cmd="cd %s;xcodebuild -exportArchive -archivePath ./build.xcarchive -exportPath ./ipa -exportOptionsPlist ./ExportOptions.plist"%(mainPath)
print(cmd)
sys.stdout.flush()
os.system (cmd)
上一篇 下一篇

猜你喜欢

热点阅读