BS fastlane的简单配置

简要记录如何通过 fastlane 和 jenkins实现自动打包上传蒲公英

环境: 1.Xcode 8.3.x 2.Jenkins 3.Fastlane

初次使用使用

1
fastlane init

输入对应的 apple id 账号和密码

下面我将粘贴 fastlane 目录结构的对应文件的内容

1
2
3
4
5
Fastlane
--- Appfile
--- Fastfile
--- Pluginfile //新版本中貌似不这样使用了

Appfile

1
2
3
4
5
6
7
app_identifier "com.XXX.app.suza.beta" # The bundle identifier of your app
apple_id "hai.duan@XXX.com.cn" # Your Apple email address
team_id "XXX" # Developer Portal Team ID
# you can even provide different app identifiers, Apple IDs and team names per lane:
# More information: https://github.com/fastlane/fastlane/blob/master/fastlane/docs/Appfile.md

Fastfile

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
# update_fastlane
# Update this, if you use features of a newer version
fastlane_version "2.23.0"
default_platform :ios
platform :ios do
before_all do
cocoapods
end
desc "Runs all the tests"
lane :test do
scan
end
desc "Submit a new Beta Build to Apple TestFlight"
desc "This will also make sure the profile is up to date"
lane :beta do
# match(type: "appstore") # more information: https://codesigning.guide
gym(scheme: "BeSquare Beta",export_method: "ad-hoc") # Build your app - more options available
#pilot
# sh "your_script.sh"
# You can also use other beta testing services here (run `fastlane actions`)
end
desc "Deploy a new version to the App Store"
lane :release do
# match(type: "appstore")
# snapshot
gym(scheme: "BeSquare Beta",export_method: "appstore") # Build your app - more options available
deliver(force: true)
# frameit
end
# You can define as many lanes as you want
after_all do |lane|
# This block is called, only if the executed lane was successful
# slack(
# message: "Successfully deployed new App Update."
# )
end
error do |lane, exception|
# slack(
# message: exception.message,
# success: false
# )
end
end

Jenkins
—- Execute shell

1
2
3
4
5
6
pwd
cd SUZA
fastlane beta
GIT_COMMIT_MSG=`git log -1 --pretty=%h:%an:%B`
curl -F "updateDescription=${GIT_COMMIT_MSG}" -F "file=@/Users/duanhai/.jenkins/workspace/XXX/XX22DD/XXX Beta.ipa" -F "uKey=27ee4291086a9ba71c2f890e3d0bdc20" -F "_api_key=729c278fe701cc64bcf9eb14d83fd2fa" https://qiniu-storage.pgyer.com/apiv1/app/upload