Homebrew
搜索
brew search jenkins
安裝
brew install jenkins
啟動(dòng)jenkins: brew services start jenkins
停止jenkins: brew services stop jenkins
重啟jenkins: brew services restart jenkins
查看jenkins: ps -ef | grep jenkins
修改默認(rèn)端口的方法:打開文件 vi /usr/local/opt/jenkins/homebrew.mxcl.jenkins.plist
修改默認(rèn)端口號(hào)httpPort
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>Label</key>
<string>homebrew.mxcl.jenkins</string>
<key>ProgramArguments</key>
<array>
<string>/usr/local/opt/openjdk@11/bin/java</string>
<string>-Dmail.smtp.starttls.enable=true</string>
<string>-jar</string>
<string>/usr/local/opt/jenkins/libexec/jenkins.war</string>
<string>--httpListenAddress=127.0.0.1</string>
<string>--httpPort=8081</string>
</array>
<key>RunAtLoad</key>
<true/>
</dict>
</plist>
~
局域網(wǎng)訪問(wèn)需要修改httpListenAddress
的值127.0.0.1
修改為0.0.0.0
卸載jenkins: brew uninstall jenkins
啟動(dòng)Jenkins
brew services start jenkins
打開網(wǎng)址:
localhost:8081
紅色路徑是Jenkins啟動(dòng)密碼路徑
進(jìn)入訪達(dá)
按住command
+shift
+g
將路徑粘貼進(jìn)入打開文件initialAdminPassword
復(fù)制密碼填寫到web位置-
安裝默認(rèn)插件
-
設(shè)置用戶名與密碼
此時(shí)基本完成Jenkins環(huán)境安裝與基礎(chǔ)配置
構(gòu)建iOS包
1 安裝插件
-
選擇系統(tǒng)管理
-
進(jìn)入插件管理
添加所需插件
- Xcode integration
- GitLab Plugin
- Gitlab Hook Plugin
- Keychains and Provisioning Profiles Management
安裝完成后重啟Jenkins,命令行 brew services restart jenkins
或http://localhost:8080/restart
個(gè)人簡(jiǎn)單來(lái)直接在網(wǎng)址后面修改
2 創(chuàng)建項(xiàng)目
參數(shù)配置
1 git地址配置
2 項(xiàng)目shell腳本打包
cocoapods 腳本
腳本命令
#bin/bsah - l
export LANG=en_US.UTF-8
export LANGUAGE=en_US.UTF-8
export LC_ALL=en_US.UTF-8
cd ${WORKSPACE}/leimingBusiness
/usr/local/bin/pod install --verbose --no-repo-update
build工程
#!/bin/bash
#注意:腳本目錄和WorkSpace目錄在同一個(gè)目錄
#工程名字(Target名字)
Project_Name="leimingBusiness"
Project_Path="${WORKSPACE}/leimingBusiness/"
#workspace的名字
Workspace_Name="leimingBusiness"
#配置環(huán)境右犹,Release或者Debug,默認(rèn)release
Configuration="Debug"
EnterpriseExportOptionsPlist="$Project_Path"EnterpriseExportOptionsPlist.plist
EnterpriseExportOptionsPlist=${EnterpriseExportOptionsPlist}
echo " ---- clear --- "
xcodebuild -workspace ${Project_Path}"$Workspace_Name.xcworkspace" -scheme "${Project_Name}" -configuration ${Configuration} clean
echo " ---- archive ---- "
xcodebuild -workspace ${Project_Path}$Workspace_Name.xcworkspace -scheme $Project_Name -configuration $Configuration -archivePath ${Project_Path}build/$Project_Name-enterprise.xcarchive archive build
xcodebuild -exportArchive -archivePath ${Project_Path}build/$Project_Name-enterprise.xcarchive -exportOptionsPlist ${EnterpriseExportOptionsPlist} -exportPath $HOME/Desktop/MyWorkPlace/自動(dòng)化打包IPAs/$Project_Name-enterprise
保存配置
上傳蒲公英操作
構(gòu)建后操作
添加兩個(gè)插件
Upload to pgyer with apiV1
Set build description
如果沒有返回Jenkins插件管理下載
// 蒲公英插件
Upload to pgyer
// 描述插件
description setter
填寫內(nèi)容
HTML 文本標(biāo)簽
<a href="${appBuildURL}"><img src="${appQRCodeURL}" width="118" height="118"/></a>
保存后 設(shè)置Jenkins HTML格式默認(rèn)Jenkins 回顯方式text
進(jìn)入 系統(tǒng)管理
-> 全局安全配置
-> 標(biāo)記格式器
發(fā)送消息到企業(yè)微信
企業(yè)微信群設(shè)置添加機(jī)器人
Jenkins安裝post build task
模板插件
sh腳本
curl 'https://qyapi.weixin.qq.com/cgi-bin/webhook/send?key=xxxxxxx' \
-H 'Content-Type: application/json' \
-d '
{
"msgtype": "news",
"news": {
"articles" : [
{
"title" : "iOS",
"description" : "測(cè)試環(huán)境",
"url" : "'${appBuildURL}'",
"picurl" : "'${appQRCodeURL}'"
}
]
}
}'
參考
Jenkins一:iOS自動(dòng)打包完整實(shí)踐
iOS持續(xù)集成—Jenkins(最新最全)
特此鳴謝
老友 田家旭
RongCloud齊新兵