一、安装方式
(一)、homebrew安装Jenkins
1、安装homebrew
https://brew.sh
卸载:/usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/uninstall)"
安装:/usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
2、安装jenkins
install the latest release version
brew install jenkins
或者
install the LTS version
brew install jenkins-lts
安装路径:/usr/local/Cellar/jenkins-lts/2.150.1
更新:brew upgrade jenkins-lts3、启动
后台服务模式:brew services start jenkins-lts
无需后台服务模式:jenkins-lts
4、停止
重新启动jenkins:brew services restart jenkins-lts
Note:如果浏览器中输入http://localhost:8080无反应,可尝试重启jenkins服务。
可用插件列表为空的解决方案
原始:http://updates.jenkins-ci.org/update-center.json
http://mirror.esuni.jp/jenkins/updates/update-center.json
(二)、WAR file
1、官网下载具体Jenkins WAR file至某一路径下
2、打开终端
3、执行 java -jar jenkisn.war,启动Jenkins服务,后续
4、浏览器:http://localhost:8080 ,即可看到Jenkins页面
note:
- You can change the port by specifying the --httpPort option when you run the java -jar jenkins.war command. For example, to make Jenkins accessible through port 9090, then run Jenkins using the command:
java -jar jenkins.war --httpPort=9090
5、之后用mac自带的automator,选择运行脚本,脚本内容为:java -jar jenkins.war,保存为应用程序,再添加至登录项,至此Jenkins自动启动完成.
(三)、tomcat
tomcat与jenkins的安装
1.homebrew 安装tomcat:brew install tomcat(tomcat路径: /usr/local/Cellar/tomcat)
2.执行startup.sh,启动tomcat
3.在浏览器中输入localhost:8080,如果能看到tomcat首页,安装就成功了
4.官网下载https://jenkins.io/index.html jenkins,将war包拷贝到/Library/tomcat/webapps下
5.执行shutdown.sh关闭tomcat,并再次启动
6.在浏览器中输入http://localhost:8080/jenkins/,如果能看到jenkins配置页面,安装就成功了
二、启动
1、http://localhost:8080,如下图:
按照提示,填写password,
2、Continue,选择“Install suggested plugins”,安装即可(可忽略,可以在系统管理->管理插件中再行安装;(若源码管理使用git,则必须安装git plugin,git client plugin))
jenkins插件下载库:http://updates.jenkins-ci.org/download/plugins/
3、在最初启动时,会要求设置Jenkins的用户名和密码,为Jenkins添加访问权限。
4、进行系统设置,目前只配置了这几个
4、创建一个自由风格的软件项目
参考:https://blog.csdn.net/taishanduba/article/details/61423121
设置Source Code Management(目前使用git)
添加相关shell,下面主要是打包(adhoc)
echo "workspace $1"
echo "jenkins_home $2"
workspace=$1
jenkins_home=$2
# 以下是用xcodebuild进行打包
# 开始build
echo "[build start ...]"
configurationBuildDir="$workspace/build"
echo "[configurationBuildDir :$configurationBuildDir]"
configuration="WiseTVAdHoc"
cd $workspace/WiseTV4.0
xcodebuild clean -configuration ${configuration}
clean_code=$?
if [[ "$clean_code" != "0" ]]; then
echo "xcodebuild clean error!"
exit 1
fi
cd ..
cd ..
workspaceName="$workspace/WiseTV4.0/WiseTV.xcworkspace"
scheme="WiseTVAdHoc"
archivePath="$configurationBuildDir/WiseTVAdHoc.xcarchive"
echo "xcodebuild archive -workspace $workspaceName -scheme $scheme -configuration $configuration -archivePath $archivePath CONFIGURATION_BUILD_DIR=$configurationBuildDir CODE_SIGN_IDENTITY=$codeSignIdentity PROVISIONING_PROFILE=$adHocProvisioningProfile"
xcodebuild -workspace ${workspaceName} -scheme ${scheme} -configuration ${configuration} archive -archivePath ${archivePath}
archive_code=$?
if [[ "$archive_code" != "0" ]]; then
echo "xcodebuild archive error!"
exit 1
fi
echo "[build success!]"
# 开始打包ipa
echo "[package ipa ...]"
exportOptionsPlist="$jenkins_home/workspace/iphoneAdHoc/WisetvExportOptions.plist"
exportPath=$configurationBuildDir
echo "xcodebuild -exportArchive -archivePath $archivePath -exportOptionsPlist $exportOptionsPlist -exportPath $exportPath"
xcodebuild -exportArchive -archivePath ${archivePath} -exportOptionsPlist ${exportOptionsPlist} -exportPath ${exportPath}
export_code=$?
if [[ "$export_code" != "0" ]]; then
echo "xcodebuild exportArchive error!"
exit 1
fi
echo "[package ipa success!]"
# echo "[clear cache ...]"
# rm -rf "$configurationBuildDir"
# echo "[clear cache success!]"
5、publish 包
1、可以使用fir plugin 上传ipa包,具体请看http://blog.fir.im/jenkins/
2、使用fir命令行publish包,具体请查看https://github.com/FIRHQ/fir-cli
如果log输出:fir command not found,可按照
https://blog.csdn.net/pengyuan_D/article/details/51861098 修改
6、构建结果邮件通知
https://www.cnblogs.com/imyalost/p/8781759.html
构建过程中问题总结:
1、xcode-select: error: tool 'xcodebuild' requires Xcode, but active developer directory '/Library/Developer/CommandLineTools' is a command line tools instance
这种情况是xcodebuild的路径不正确
将路径切换到xcode的目录下:
sudo xcode-select --switch /Applications/Xcode.app/Contents/Developer/
然后执行xcodebuild -showsdks查看是否正常使用
2、xcodebuild 命令详解
https://www.jianshu.com/p/770d5df137bf
3、获取fir api token
https://www.betaqr.com/apps/apitoken
当前:737b8fca97cc6e094951449884f263d5
三、fir.im-cli指令上传ipa包
fir cli https://github.com/FIRHQ/fir-cli/tree/master/doc
安装:
$ ruby -v # > 2.6.1
$ gem install fir-cli
登录:
fir login token
fir me
更新:
fir upgrade
发布:
fir publish APP_FILE_PATH
四、在jenkins中使用fir-plugin
安装fir-plugin,或者下载此插件,然后在jenkins插件管理中上传使用
添加Post-build Actions,选择upload to fir.im.
填写token,可以使用链接查看https://www.betaqr.com/apps/apitoken,因为fir的域名的更改,文档中的链接不支持查看。填写ipa包所在路径,因为会自动上传路径下所有的ipa包,所以这里做了一个操作,将要上传的ipa包拷贝至了一个特定的路径(mv $WORKSPACE/build/Apps/WiseTVAdHoc.ipa /Users/dongranran/Public/ipa/),如下图
Jenkins官网:https://jenkins.io
Jenkins Pipeline总体介绍 https://blog.csdn.net/diantun00/article/details/81075007