jenkins自动打包配置

电脑安装jenkins环境,自行百度,详细介绍jenkins项目配置
jenkins主页面:
  • 选择-系统管理-进行配置


    jenkins自动打包配置_第1张图片
    image
系统管理页面如下,需要配置的
  • 系统配置
  • 全局安全配置
  • 插件管理
  • Keychains and Provisioning Profiles Management
jenkins自动打包配置_第2张图片
image
  • 系统配置
Keychains and Provisioning Profiles Management

/Users/Shared/Jenkins/Library/MobileDevice/Provisioning Profiles 

- keychains

login.keychain-db

${HOME}/Library/Keychains/login.keychain

钥匙串密码

jenkins自动打包配置_第3张图片
1901627-ade76046e4073492.png

2.全局安全配置


jenkins自动打包配置_第4张图片
image

3.Keychains and Provisioning Profiles Management


jenkins自动打包配置_第5张图片
1901627-d591f01d6a41e056.png

4.凭据

jenkins自动打包配置_第6张图片
image
  • APIToken


    jenkins自动打包配置_第7张图片
    1901627-13db7a8ecf3e5abe.png
  • Usernama password


    jenkins自动打包配置_第8张图片
    1901627-cc4c9c03870a9284.png
  • sshkey
jenkins自动打包配置_第9张图片
1901627-4e64626a29460f69.png

5.项目配置

  • 打包脚本
#项目名
PROJECT_NAME="****"
# 工程名
APP_NAME=${scheme}

# 证书
ADHOCCODE_SIGN_IDENTITY="iPhone Developer: ****"

# 描述文件
ADHOCPROVISIONING_PROFILE_NAME="*****"


BundleID=${BundleID}

#打包名字
EXPORTOPTIONS_NAME="***ExportOptions.plist"


# info.plist路径
project_infoplist_path="./${APP_NAME}/Config/Info.plist"

#取版本号
bundleShortVersion=$(/usr/libexec/PlistBuddy -c "print CFBundleShortVersionString" "${project_infoplist_path}")

#取build值
bundleVersion=$(/usr/libexec/PlistBuddy -c "print CFBundleVersion" "${project_infoplist_path}") 
#根据时间修改build值
bundleVersion="$(date +"%Y%m%d%H%M")"     
/usr/libexec/PlistBuddy -c "Set :CFBundleVersion $bundleVersion" "${project_infoplist_path}"

#文件名
DATE="$(date +%Y%m%d)"
IPANAME="${APP_NAME}_V${bundleShortVersion}_${DATE}.ipa"

#要上传的ipa文件路径
IPA_PATH="./TEMP_IPA/${IPANAME}"
echo ${IPA_PATH}
echo "${IPA_PATH}"> text.txt


#修改签名信息
sed -i "" s/'CODE_SIGN_STYLE = Automatic;'/'CODE_SIGN_STYLE = Manual;'/g ${PROJECT_NAME}.xcodeproj/project.pbxproj


#钥匙串密码
/usr/bin/security unlock-keychain -p ***

echo "=================开始clean================="
xcodebuild clean -configuration ${environment} -alltargets
echo "=================结束clean================="


echo "+++++++++++++++++开始编译+++++++++++++++++"
xcodebuild archive -workspace "${PROJECT_NAME}.xcworkspace" -scheme ${APP_NAME} -sdk iphoneos -configuration ${environment} CODE_SIGN_IDENTITY="${ADHOCCODE_SIGN_IDENTITY}" PROVISIONING_PROFILE="${ADHOCPROVISIONING_PROFILE_NAME}" PRODUCT_BUNDLE_IDENTIFIER="${BundleID}" -archivePath "./${environment}-iphoneos/${APP_NAME}.xcarchive"



echo "+++++++++++++++++结束编译+++++++++++++++++"



echo "+++++++++++++++++集成ipa+++++++++++++++++"
xcodebuild -exportArchive -archivePath "./${environment}-iphoneos/${APP_NAME}.xcarchive" -exportOptionsPlist ./${EXPORTOPTIONS_NAME} -exportPath "./TEMP_IPA" -allowProvisioningUpdates
echo "+++++++++++++++++打包完成+++++++++++++++++"

mv ./TEMP_IPA/*.ipa ${IPA_PATH} 

#蒲公英上的User Key
uKey="****"

#蒲公英上的API Key
apiKey="**********"

#要上传的ipa文件路径
IPA_PATH=$(cat text.txt)

rm -rf text.txt

#执行上传至蒲公英的命令
echo "++++++++++++++上传IPA+++++++++++++"
appShortcutUrl=`curl -F "file=@${IPA_PATH}" -F "uKey=${uKey}" -F "_api_key=${apiKey}" http://www.pgyer.com/apiv1/app/upload|grep appShortcutUrl|awk -F ',"appShortcutUrl":' '{print $2}'|cut -d, -f1|sed 's/"//'|sed 's/"//'`
echo "++++++++++++++上传完成+++++++++++++"


1901627-07c6e37fe80d1e51.png

你可能感兴趣的:(jenkins自动打包配置)