ios/macos Jenkins+fastlane安装和配置问
2022-09-05 本文已影响0人
Jesscia_Liu
此篇文章解释jenkins+fastlane安装和配置过程中遇到的问题和解决方法
以目前最新版本jenkins为例:即jenkins2.346.3
fastlane安装讲解见我的另一篇文章:Fastlane的集成和使用 包括 ios/mac 项目示例
jenkins安装和配置见我的另一篇文章:macos12 Jenkins 最新版本 安装和项目配置
一、brew安装jenkins失败
~ % brew install jenkins-lts httpPort=8090
Error
- 更新java JDK版本
- 去掉httpPort=8090,安装成功后,再在设置页修改端口号(修改端口号方法见以下说明二、)即可
~ % brew install jenkins-lts
Success
二、jenkins管理界面,提示“反向代理设置有误”解决方法
以homebrew安装的jenkins为例:
- 查看jenkins安装路径(cmd+shift+g "/usr/local/opt/jenkins")下的配置文件.plist中设置的ip地址和端口号
- 查看jenkins web前端界面:系统管理--->系统配置(Configure System)--->Jenkins Location--->Jenkins URL的ip和端口号
- 3.需要保证两处一致

解决方法
-
- mac电脑查看本机ipv4地址:
- 方法一:终端输入: ipconfig getifaddr en0
- 方法二:系统偏好设置-网络-wifi-高级-TCP/IP-IPv4地址
-
- 找到jenkins安装目录
- homebrew安装Jenkins的路径为/usr/local/opt/jenkins/homebrew.mxcl.jenkins.plist (或/usr/local/opt/jenkins-lts/homebrew.mxcl.jenkins-lts.plist)
-
打开homebrew.mxcl.jenkins.plist文件,找到查看默认ip地址(127.0.0.1)和端口号(8090),如图:
homebrew.mxcl.jenkins.plist.png
-
- 修改为:步骤1中的本机ipv4地址和任意端口号如8090
- 浏览器输入 本机ipv4地址:8090/configure,修改Jenkins URL改为 http://本机ipv4地址:8090/

三、手动配置Keychains and Provisioning Profiles Management点上传按钮无反应
- 系统管理-插件管理-搜索并安装Keychains and Provisioning Profiles Management
- 安装成功后找到 系统管理-最下方未分类的 Keychains and Provisioning Profiles Management,点击进入


- 网上较多说换低版本的jenkins如2.263.4就能解决,但是截止到今天这种方法是不行的。因为好多插件已有更新的最低版本,就算安装了2.263.4这种低版本的jenkins,好多插件也不能安装。(首次安装jenkins选择安装默认推荐的插件选项时,在安装插件过程中很多插件安装失败显示红叉叉。)

- 所以正确方法应该是不用这个插件,直接使用项目的git地址加gitlab用户名和密码加脚本配置jenkins,即可成功构建项目,项目配置如图(我司使用gitlab管理代码,其他方式按需填写)。


四、立即构建报错:分支设置错误
ERROR: Couldn't find any revision to build. Verify the repository and branch configuration for this job.
Finished: FAILURE
- 这是因为分支信息设置错误,需要修改项目的分支信息
- 项目名-配置-源码管理-Branches to build-Add Branch-指定分支填: ** ,即默认所有分支

五、fastlane: command not found
+ sh ./fastlane/Fastlane.sh
./fastlane/Fastlane.sh: line 3: fastlane: command not found

- 使用脚本构建项目报错,但用此脚本在终端执行正常。
解决方法
-
在我们保证我们安装的fastlane没有问题的基础上要是出现这种问题(即终端可正确执行fastlane lane任务名 🎉> ),那就一般是由于 jenkins 没有设置正确的 $PATH 环境变量导致的。正确设置的方法为:
1、在命令行下执行 echo $PATH,记录下输出的结果
2、在 jenkins 中 系统管理 - 系统配置(Configure System) - 向下拉找到全局属性 - 勾选环境变量 - 添加键值对列表
3、在 key 中填写 PATH,在 value 中填写第一步中输出的结果
4、保存即可。
键值对列表-新建.png
六、 fastlane requires your locale to be set to UTF-8
[!] Error building the application - see the log above�[0m
[15:27:37]: �[31mWARNING: fastlane requires your locale to be set to UTF-8\. To learn more go to [https://docs.fastlane.tools/getting-started/ios/setup/#set-up-environment-variables�[0m](https://docs.fastlane.tools/getting-started/ios/setup/#set-up-environment-variables�[0m)
Build step 'Execute shell' marked build as failure
Finished: FAILURE
解决方法
-
同 五、在 jenkins 中 系统管理 - 系统配置(Configure System) - 向下拉找到全局属性 - 勾选环境变量 - 添加键值对列表,添加以下配置:
LANG en_US.UTF-8
LC_ALL en_US.UTF-8

没有💥,完结🎉说明全部成功

七、全局安全配置时 User not found:xxx

解决方法
- 在确保用户名真实存在的情况下,刷新页面即可

八、使用scp方式上传给服务器已经打好的包文件,报错OpenSSH keys
/Library/Ruby/Gems/2.6.0/gems/net-ssh-6.1.0/lib/net/ssh/authentication/ed25519_loader.rb:21:in `raiseUnlessLoaded': OpenSSH keys only supported if ED25519 is available (NotImplementedError)
net-ssh requires the following gems for ed25519 support:
* ed25519 (>= 1.2, < 2.0)
* bcrypt_pbkdf (>= 1.0, < 2.0)
See https://github.com/net-ssh/net-ssh/issues/565 for more information
Gem::MissingSpecError : "Could not find 'ed25519' (~> 1.2) among 203 total gem(s)
解决方法
- 执行fastlane lane上传到服务器前先执行以下代码,注意当前目录定位在项目路径下。
- 或在fastlane.sh脚本文件执行 fastlane lane名前加以下代码也可。
ssh-add
九、gem install 权限错误
You don't have write permissions for the /Library/Ruby/Gems/2.6.0 directory.
- 终端执行
~ % export GEM_HOME="$HOME/.gem"
- 或配置 cmd+shift+G ~/.bash_profile,加入如下内容
# gem install 权限
export GEM_HOME="$HOME/.gem"
- 若终端fastlane lane任务 执行成功,但jenkins配置的fastlane失败,需要在fastlane.sh脚本文件中加入此语句,或者在jenkins系统配置中shell脚本配置里加上此语句
参考文章
Jenkins 100次构建失败踩坑全录(一)
记我Jenkins创建任务时错误
iOS自动化打包 Jenkins+Gitlab+Fastlane+蒲公英+钉钉