一、jenkins安装
通过homebrew安装jenkins
brew install Jenkins
如果没有安装homebrew的话,需要先安装homebrew
该命令可以选择国内源安装,推荐使用
/bin/zsh -c "$(curl -fsSL https://gitee.com/cunkai/HomebrewCN/raw/master/Homebrew.sh)"
开启jenkins
brew services start jenkins
关闭jenkins
brew services stop Jenkins
重启jenkins
brew services restart Jenkins
使用brew安装 Jenkins,能解决一些权限问题,但是默认配置为 localhost:8080,不能通过ip访问。需要修改homebrew.mxcl.jenkins.plist来允许ip访问。
通过where查询jenkins安装路径
where jenkins
查询路径为:
/opt/homebrew/bin/jenkins
修改端口号
通过以下路径找到配置文件
/opt/homebrew/Cellar/jenkins/2.305/homebrew.mxcl.jenkins.plist
修改httpPort为 8088,httpListenAddress为0.0.0.0或者本机ip地址。
<?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>/opt/homebrew/opt/openjdk@11/bin/java</string>
<string>-Dmail.smtp.starttls.enable=true</string>
<string>-jar</string>
<string>/opt/homebrew/opt/jenkins/libexec/jenkins.war</string>
<string>--httpListenAddress=0.0.0.0</string>
<string>--httpPort=8088</string>
</array>
<key>RunAtLoad</key>
<true/>
</dict>
</plist>
修改后重启jenkins即可
二、jenkins使用
1.一个任务下管理多个git仓库
1.安装Multiple SCMs
在 系统管理 -> 插件管理 搜索 Multiple SCMs并安装


2.配置
1.创建任意风格的任务,并进行配置

2.添加一个git仓库

3.添加git仓库账号密码

4.检出到子目录

这里命名为:仓库1

5.添加第二个仓库,步骤跟添加第一个一样。

2.自定义工作空间

注意:必须使用绝对路径!

3.配置构建后的目录

这里的路径是相对于workspace的路径。拿仓库1来说,这里的ipa/
就是仓库1目录下的ipa文件夹。注意一定要带/
,是ipa/
而不是ipa
。不然jenkins按照文件查找而不是文件夹。

三、jenkins问题解决
1.中文编码问题。
在使用xcodeproj进行配置修改的时候,报错:/Library/Ruby/Gems/2.6.0/gems/xcodeproj-1.21.0/lib/xcodeproj/plist.rb:91:in `match': invalid byte sequence in US-ASCII (ArgumentError)
/Library/Ruby/Gems/2.6.0/gems/xcodeproj-1.21.0/lib/xcodeproj/plist.rb:91:in `match': invalid byte sequence in US-ASCII (ArgumentError)
from /Library/Ruby/Gems/2.6.0/gems/xcodeproj-1.21.0/lib/xcodeproj/plist.rb:91:in `match'
from /Library/Ruby/Gems/2.6.0/gems/xcodeproj-1.21.0/lib/xcodeproj/plist.rb:91:in `file_in_conflict?'
from /Library/Ruby/Gems/2.6.0/gems/xcodeproj-1.21.0/lib/xcodeproj/plist.rb:20:in `read_from_path'
from /Library/Ruby/Gems/2.6.0/gems/xcodeproj-1.21.0/lib/xcodeproj/project.rb:211:in `initialize_from_file'
from /Library/Ruby/Gems/2.6.0/gems/xcodeproj-1.21.0/lib/xcodeproj/project.rb:113:in `open'
from /Users/leo/.jenkins/workspace/test01/FHClientDemo/Script/../../publish/手机用户端-t-t-0818_1049/FHClientDemo/config_demo_publish.rb:40:in `<main>'
解决方案:
在jenkins构建脚本里加如以下代码:
export LC_ALL=en_US.UTF-8
export LANG=en_US.UTF-8

网友评论