1.下载jenkins,方式有两种,一种是直接去jenkins官网下载:https://jenkins.io;另外一种是通过命令下载:brew install jenkins;按照网上安装的经验和自己亲自安装的感受来说,建议用命令安装比较好(网上有人说通过官网下载的话会遇到各种坑,本人通过官网下载时,最后打包的时候一直提示provisioning profile配置文件的问题,但是卸载之后,通过命令安装的话就不会存在此问题,可以正常打包成功了,可以供大家参考)
2.初始的管理员密码,jenkins自动生成的,根据下面红色箭头标注的路径找到密码,拷到下面的输入框中。

3.安装插件,可以默认的安装,也可以自己选择,(jenkins配置好后也可以安装插件)这里我们选择默认的。


4.完了以后创建用户

5.创建完用户后进入jenkins主页,选择新建一个item

6.进入之后,按照以下方式创建任务

7.进入之后的相关配置





将以下配置内容粘贴在上图红色箭头标注的框里面
#!/bin/bash
jenkinsDownloadedPath=${JENKINS_HOME}/workspace/${JOB_NAME}/
workspaceName=“test”
schemeName="test"
workspacePath=$jenkinsDownloadedPath$workspaceName".xcworkspace"
archivePath=$jenkinsDownloadedPath"/build/test"${env}${BUILD_TIMESTAMP}".xcarchive"
exportPath=$jenkinsDownloadedPath"/ipa/"$env
exportOptionsPlistPath=$jenkinsDownloadedPath"exportOptions.plist"
xcodebuildDefaultIpaPath=$jenkinsDownloadedPath"ipa/"$env"/test.ipa"
uploadToServerIpaPath=$jenkinsDownloadedPath"ipa/"$env"/test"-${env}-${BUILD_TIMESTAMP}".ipa"
serverIpaFolderPath="root@192.168.214.123:/root/testIOSIpa"
xcodebuild archive -workspace ${workspacePath} -scheme ${schemeName} -configuration $env -archivePath ${archivePath}
xcodebuild -exportArchive -archivePath ${archivePath} -configuration $env -exportPath ${exportPath} -exportOptionsPlist ${exportOptionsPlistPath}
cp ${xcodebuildDefaultIpaPath} ${uploadToServerIpaPath}
scp ${uploadToServerIpaPath} ${serverIpaFolderPath}
将以下箭头标注的内容改成自己的内容即可

网友评论