代码检测
# 生成用于后续代码检测的解析文件
#!/bin/sh
set +e
source ~/.bash_profile
cd MCShow
export LANG=en_US.UTF-8
swiftlint lint --path MCShow > MCShow-swiftlint.txt
echo $?
环境配置
cd MCShow
export LANG=en_US.UTF-8
# 操作Jenkins打包环境配置
if [ "$Environment" == "ONLINE" ];then
echo "0" > ./domain_config
elif [ "$Environment" == "RELEASE" ];then
echo "1" > ./domain_config
elif [ "$Environment" == "TEST" ];then
echo "2" > ./domain_config
elif [ "$Environment" == "DEV" ];then
echo "3" > ./domain_config
fi
拷贝依赖
startInfo="开始引入依赖库"
endInfo="依赖库引入完成"
source ~/.bash_profile
cd MCShow
export LANG=en_US.UTF-8
export https_proxy=http://10.0.72.225:7890 http_proxy=http://10.0.72.225:7890 all_proxy=socks5://10.0.72.225:7890
echo $startInfo
pod install
echo $endInfo
# 拷贝资源库
# targetUmdevicePath="./Pods/UMDevice/UMDevice_1.1.0/UMDevice.framework/"
# srcUmdevicePath="../Resource/libs/UMDevice.framework/"
# rm -rf $targetUmdevicePath
# cp -r $srcUmdevicePath $targetUmdevicePath
# 拷贝融云资源
targetRongcloudPath="./Pods/RongCloudIM/RongCloudIM/RongCloud.bundle/"
srcRongcloudPath="../Resource/RongCloud.bundle/"
rm -rf $targetRongcloudPath
cp -r $srcRongcloudPath $targetRongcloudPath
分发
offical="Fir.im-Official"
standby="Fir.im-Standby"
testflight="TestFlight"
source ~/.bash_profile
cd MCShow
export LANG=en_US.UTF-8
echo "授权钥匙串访问权限"
security unlock-keychain -p 111111 $HOME/Library/Keychains/login.keychain
echo "开始打包"
checkIpa(){
fileName="MCShow.ipa"
filePath="app/$fileName"
fileCreateTimeInterval=`date -r "$filePath" +%s`
nowTimeInterval=`date +%s`
diff=$(($fileCreateTimeInterval-$nowTimeInterval))
if [ 0 -gt $diff ];then
let diff=0-$diff
fi
limitTimeInterval=1800
if [ $diff -gt $limitTimeInterval ];then
echo "安装包检测有问题";
exit 2005
fi
}
firPublish(){
fir publish app/MCShow.ipa --token=$1 --specify-icon-file=fastlane/logo.jpg --changelog=$ReleaseNotes
}
if [ "$ShowPlatform" == "$offical" ];then
echo $offical;
fastlane archive;
echo "打包结束"
checkIpa;
firPublish 9e878f3339b1c1efb036ccf17ca96072;
elif [ "$ShowPlatform" == "$standby" ];then
echo $standby;
fastlane archive;
echo "打包结束"
checkIpa;
firPublish 909f3f4743198a622a0540c0685beab7;
elif [ "$ShowPlatform" == "$testflight" ];then
echo $testflight;
fastlane beta;
echo "打包结束"
fi
通知
cd MCShow
export LANG=en_US.UTF-8
source ~/.bash_profile
appName=""
appVersion=""
appBuild=""
appBundleId=""
platform="iOS"
getAppInfo(){
basePath=`pwd`
ipaFilePath="$basePath/app/MCShow.ipa"
if [ ! -f "$ipaFilePath" ]; then
echo "未找到ipa包 $ipaFilePath"
exit 2002
fi
temIpaDirName="TempPayload"
temIpaDirPath="${basePath}/${temIpaDirName}"
if [ -d "$temIpaDirPath" ]; then
rm -rf "${temIpaDirPath}"
fi
if [[ -f "$ipaFilePath" ]]; then
unzip "$ipaFilePath" -d "$temIpaDirPath"
fi
appDir="$temIpaDirPath/Payload/`ls "$temIpaDirPath/"Payload`"
lcmInfoPlist="${appDir}/Info.plist"
appName=`/usr/libexec/PlistBuddy -c "Print :CFBundleDisplayName" $lcmInfoPlist`
appVersion=`/usr/libexec/PlistBuddy -c "Print :CFBundleShortVersionString" $lcmInfoPlist`
appBuild=`/usr/libexec/PlistBuddy -c "Print :CFBundleVersion" $lcmInfoPlist`
appBundleId=`/usr/libexec/PlistBuddy -c "Print :CFBundleIdentifier" $lcmInfoPlist`
if [ -d "$temIpaDirPath" ]; then
rm -rf "${temIpaDirPath}"
fi
}
getAppInfo
offical="Fir.im-Official"
standby="Fir.im-Standby"
testflight="TestFlight"
if [ "$ShowPlatform" == "$testflight" ];then
exit 2001
fi
#钉钉通知
accessToken="c50924ce66e3f842e454089c2f6e75222892d56e9e7f143ef8c235539a66f984"
iconUrl="<https://tva1.sinaimg.cn/large/008eGmZEly1gomwuhsuu7j305k05k748.jpg>"
downloadUrl="<http://fir.renchengqi.com/showios>"
if [ "$ShowPlatform" == "$offical" ];then
downloadUrl="<http://fir.hulai.com/shai>"
accessToken="c50924ce66e3f842e454089c2f6e75222892d56e9e7f143ef8c235539a66f984"
fi
url="<https://oapi.dingtalk.com/robot/send?access_token=$accessToken>"
header="Content-Type: application/json"
title="$appName($platform)更新"
text="[$appName($platform)更新]($downloadUrl)\\n\\n \\
\\n\\n \\
链接:[$downloadUrl]($downloadUrl)\\n\\n \\
版本: $appVersion (Build: $appBuild)\\n\\n \\
更新内容: $ReleaseNotes\\n\\n \\
Git记录: [<https://jenkins.hulai.com/view/shai/job/shai-ios/${BUILD_NUMBER}/changes>](<https://jenkins.hulai.com/view/sh>...