1,安装:brew install jenkins
2,命令行里:jenkins 回车,第一次会生成密码和保存密码的路径如:/Users/uname/.jenkins/secrets/initialAdminPassword
3,Jenkins中配置Xcode工程:
Manage Jenkins->pluginManager->available 查找xcode插件安装
4,创建一个新任务,输入项目名称,选择“构建一个自由风格的软件项目”
General设置Discard old builds,This project is parameterized :name iOS_BRANCH branch:*/${iOS_BRANCH},设置分支参数choice parameter,multi-line string parameter设置蒲公英等描述信息
5,Additional Behaviours,advanced clone betaviours, fetch tags,Shallow clone,Shallow clone depth0,timeout 60;
6, Build -> execute shell #sh /Users/aaa/hello.sh $BUILD_NUMBER $WORKSPACE Release
7, 安装上传到蒲公英的插件

遇到问题jenkins启动不了,使用jenkins --httpPort=8080启动,端口占用后换端口号

脚本如下:

pod install

if [ ! -d build ];then
mkdir build
fi

PROJECT_NAME=${JOB_NAME}
# 1 clean
xcodebuild clean -workspace $WORKSPACE"/"$PROJECT_NAME".xcworkspace" -configuration Release -scheme $PROJECT_NAME
# # 2 导出 archive
xcodebuild archive -workspace $WORKSPACE"/"$PROJECT_NAME".xcworkspace" -scheme $PROJECT_NAME \
-archivePath ${PROJECT_NAME}.xcarchive -allowProvisioningUpdates
# 3 导出ipa
xcodebuild -exportArchive -archivePath ${PROJECT_NAME}.xcarchive -exportPath ./build -exportOptionsPlist ExportOptions.plist

# 上传到蒲公英 / 或者用插件也行 | ukey apikey都是和app对应的
curl -F "file=@./build/"${PROJECT_NAME}".ipa" \
-F "uKey=key" \
-F "_api_key=sdjfklasdjfklsd" \
-F "buildUpdateDescription=${PGYER}" \
https://www.pgyer.com/apiv2/app/upload

git commit 修改内容:

CHANGELOG=$(curl -u username:password  "http://1.1.1.1:8080/job/$JOB_NAME/$BUILD_NUMBER/api/xml?wrapper=changes&xpath=//changeSet//comment"  | sed -e "s/<\/comment>//g; s/<comment>//g; s/<\/*changes>//g" | sed '/^$/d;G' | sed 's/&amp;//g')

05-11 11:29