Jenkins + iOS打包 + 蒲公英上傳

Jenkins.jpg

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)端口的方法:打開(kāi)文件 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

  1. brew services start jenkins

  2. 打開(kāi)網(wǎng)址:localhost:8081

初始化.jpeg
  1. 紅色路徑是Jenkins啟動(dòng)密碼路徑
    進(jìn)入訪達(dá) 按住 command + shift + g 將路徑粘貼進(jìn)入打開(kāi)文件initialAdminPassword復(fù)制密碼填寫(xiě)到web位置

  2. 安裝默認(rèn)插件


    1.jpeg

    2.jpeg

    3.jpeg
  3. 設(shè)置用戶(hù)名與密碼


    用戶(hù)設(shè)置.jpeg

此時(shí)基本完成Jenkins環(huán)境安裝與基礎(chǔ)配置

構(gòu)建iOS包

1 安裝插件

  1. 選擇系統(tǒng)管理


    首頁(yè).png
  2. 進(jìn)入插件管理


    系統(tǒng)配置.png
  3. 添加所需插件

  1. Xcode integration
  2. GitLab Plugin
  3. Gitlab Hook Plugin
  4. Keychains and Provisioning Profiles Management
1.png

安裝完成后重啟Jenkins,命令行 brew services restart jenkinshttp://localhost:8080/restart
個(gè)人簡(jiǎn)單來(lái)直接在網(wǎng)址后面修改

2 創(chuàng)建項(xiàng)目

1.png

參數(shù)配置

1 git地址配置

2.png
2.2.png

2 項(xiàng)目shell腳本打包

3.png
cocoapods 腳本
3.1.png

腳本命令

#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工程
3.2.png
#!/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

如果沒(méi)有返回Jenkins插件管理下載

// 蒲公英插件
Upload to pgyer
// 描述插件
description setter
1.png

填寫(xiě)內(nèi)容


2.png

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)記格式器

3.png

發(fā)送消息到企業(yè)微信

企業(yè)微信群設(shè)置添加機(jī)器人

Jenkins安裝post build task模板插件

image.png

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(最新最全)

最后編輯于
?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請(qǐng)聯(lián)系作者
【社區(qū)內(nèi)容提示】社區(qū)部分內(nèi)容疑似由AI輔助生成,瀏覽時(shí)請(qǐng)結(jié)合常識(shí)與多方信息審慎甄別。
平臺(tái)聲明:文章內(nèi)容(如有圖片或視頻亦包括在內(nèi))由作者上傳并發(fā)布,文章內(nèi)容僅代表作者本人觀點(diǎn),簡(jiǎn)書(shū)系信息發(fā)布平臺(tái),僅提供信息存儲(chǔ)服務(wù)。

友情鏈接更多精彩內(nèi)容