Homebrew
搜索
brew search jenkins
安装
brew install jenkins
启动jenkins: brew services start jenkins
停止jenkins: brew services stop jenkins
重启jenkins: brew services restart jenkins
查看jenkins: ps -ef | grep jenkins
修改默认端口的方法:打开文件 vi /usr/local/opt/jenkins/homebrew.mxcl.jenkins.plist
修改默认端口号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>
~
局域网访问需要修改httpListenAddress
的值127.0.0.1
修改为0.0.0.0
卸载jenkins: brew uninstall jenkins
启动Jenkins
brew services start jenkins
打开网址:
localhost:8081
红色路径是Jenkins启动密码路径
进入访达
按住command
+shift
+g
将路径粘贴进入打开文件initialAdminPassword
复制密码填写到web位置-
安装默认插件
-
设置用户名与密码
此时基本完成Jenkins环境安装与基础配置
构建iOS包
1 安装插件
-
选择系统管理
-
进入插件管理
添加所需插件
- Xcode integration
- GitLab Plugin
- Gitlab Hook Plugin
- Keychains and Provisioning Profiles Management
安装完成后重启Jenkins,命令行 brew services restart jenkins
或http://localhost:8080/restart
个人简单来直接在网址后面修改
2 创建项目
参数配置
1 git地址配置
2 项目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目录在同一个目录
#工程名字(Target名字)
Project_Name="leimingBusiness"
Project_Path="${WORKSPACE}/leimingBusiness/"
#workspace的名字
Workspace_Name="leimingBusiness"
#配置环境,Release或者Debug,默认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/自动化打包IPAs/$Project_Name-enterprise
保存配置
上传蒲公英操作
构建后操作
添加两个插件
Upload to pgyer with apiV1
Set build description
如果没有返回Jenkins插件管理下载
// 蒲公英插件
Upload to pgyer
// 描述插件
description setter
填写内容
HTML 文本标签
<a href="${appBuildURL}"><img src="${appQRCodeURL}" width="118" height="118"/></a>
保存后 设置Jenkins HTML格式默认Jenkins 回显方式text
进入 系统管理
-> 全局安全配置
-> 标记格式器
发送消息到企业微信
企业微信群设置添加机器人
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" : "测试环境",
"url" : "'${appBuildURL}'",
"picurl" : "'${appQRCodeURL}'"
}
]
}
}'
参考
Jenkins一:iOS自动打包完整实践
iOS持续集成—Jenkins(最新最全)
特此鸣谢
老友 田家旭
RongCloud齐新兵