env.build_file_name="_.ipa" env.publishChannel="" env.outpath="/Volumes/volume2/download" env.subpath="" env.buildUser="" env.DistOutputPath="/Volumes/volume2/pandora_ipa" pipeline { environment { PATH="/usr/local/share/dotnet/x64:/usr/local/bin:${PATH}" unity_app="/Applications/Unity/Unity.app/Contents/MacOS/Unity" sharePath="${WORKSPACE}/pandora_share_proj" pandora_cli_proj = "${WORKSPACE}/pandora_cli_proj" pandora_pro_dir= "${pandora_cli_proj}/pandora" build_graph="Assets/ZXToolkit/AssetGraph/Graph/BuildGraph.asset" log_dir="${WORKSPACE}/log/ios" buid_name="pandora_${publishChannel}_${version}_date" disableLog="false" lang="en" gameIP="111.231.250.180" maintenanceIP="111.231.250.180" feshu_url="8d1b6a92-fd8c-4c58-9e81-b2912ee1a641" // SVN_Credentials=credentials('PANDORA_SVN_TOKEN') } agent { node { label 'mac' } } stages { stage('InitPyEnv') { steps{ sh label: '', script:''' python3 -m pip install -i https://pypi.tuna.tsinghua.edu.cn/simple psutil python3 -m pip install -i https://pypi.tuna.tsinghua.edu.cn/simple requests ''' } } stage('pre process') { steps { sh label: '', script:''' cd ${WORKSPACE} python3 ./build_ci/cache_files.py ${WORKSPACE} pandora_cli_proj/pandora/ProjectSettings/ProjectSettings.asset tmp/orgin/ProjectSettings.asset tmp/cache/ProjectSettings.asset ''' } } stage('更新cli和share代码') { steps { sh label: '', script:''' python3 ./build_ci/u2c/CheckoutShare.py ${Branch} share /usr/local/bin/svn false guojiannan jiannan10 python3 ./build_ci/u2c/CheckoutShare.py ${Branch} client /usr/local/bin/svn false guojiannan jiannan10 ''' } } stage('编译ExcelExcelExpor') { steps { script{ sh """ echo ${env.PATH} cd ${env.sharePath}/ExcelExport chmod 774 excelTolua.py chmod 774 ExportLanguageToText.py python3 ./excelTolua.py region jp python3 ./ExportLanguageToText.py """ } } } stage('编译proto') { steps { script{ sh """ cd ${env.sharePath}/protocol chmod 774 export_lua.py python3 ./export_lua.py """ } } } stage('Set Env Value') { steps { script{ // 设置默认渠道 env.publishChannel = "${publishChannel}" ?: "ios_oversea" if ("${config_flag}" == "JP") { env.publishChannel = "ios_japan" } if ("${config_flag}" == "SEA") { env.publishChannel = "ios_southeast" } if ("${config_flag}" == "KR") { env.publishChannel = "ios_korea" } timestamp = new Date().format('yyyyMMddHHmmss') // 构建名称 buid_name = "pandora_${publishChannel}_${version}_${timestamp}" echo "$buid_name" if ("${debug}" == "true") { buid_name = "${buid_name}_debug" } echo "$buid_name" // 输出文件名 env.build_file_name = "${buid_name}" if ("${mode}" == "aab") { env.build_file_name = "${buid_name}.aab" } //env.subpath = "${env.subpath}/${env.publishChannel}/${target}/${version}/${mode}/${timestamp}" //echo "${env.outpath}" env.outpath = "${env.pandora_cli_proj}/build/XcodeProject" echo "${env.outpath}" } } } stage('ProcessTextureFormat') { steps { sh label: '', script:''' ${unity_app} -quit -batchmode -buildTarget ${target} -projectPath ${pandora_pro_dir} -logFile - -executeMethod XAsset.Build.AssetBuildScript.ProcessTextureFormat graph="Assets/ZXToolkit/AssetGraph/Graph/SpineImageImporter.asset" target=${target} ''' } } stage('Build') { steps { sh label: '', script:''' cd ${pandora_cli_proj} python3 ${pandora_cli_proj}/../pandora_share_proj/MacBuild/build_generate_common.py debug=${debug} version=${version} disableLog=${disableLog} versionIP="${versionIP}" versionPort=${versionPort} mode=${mode} publishChannel=${publishChannel} gameIP=${gameIP} maintenanceIP=${maintenanceIP} lang=${lang} cd ${pandora_cli_proj} python3 $pandora_cli_proj/../pandora_share_proj/MacBuild/build_generate_common.py debug=$debug version=$version disableLog=$disableLog versionIP="${versionIP}" mode=$mode publishChannel=$publishChannel gameIP=$gameIP maintenanceIP=$maintenanceIP lang=$lang $unity_app -quit -batchmode -buildTarget ${target} -projectPath ${pandora_pro_dir} -logFile "${log_dir}/${buid_name}.log" -executeMethod XAsset.Build.AssetBuildScript.RunBuild version=$version config_flag=$config_flag isUsingUWAPoco=$isUsingUWAPoco outpath=$outpath development=$development thinkingAnalyticsMode=$thinkingAnalyticsMode versionIP=$versionIP mode=$mode publishChannel=$publishChannel graph=$build_graph target=$target ''' } } stage("copy custom files"){ steps{ sh label: '', script:''' copy() { local source=$1 local target=$2 if [ -f $source ]; then cp "$source" "$target" elif [ -d $source ]; then mkdir -p "$target" for item in "$source"/* do copy "$item" "$target/${item##*/}" done fi } copy_files() { local source=$1 local target=$2 copy "$source" "$target" } copy_files "${WORKSPACE}/iOS/JP" "${outpath}" ''' } } stage('DS') { steps { sh label: '', script:''' /usr/libexec/PlistBuddy -c 'Set:CFBundleShortVersionString "1.0.'${BundleVersion}'"' ${outpath}/Info.plist /usr/libexec/PlistBuddy -c 'Set:CFBundleVersion "'${BundleVersion}'"' ${outpath}/Info.plist /usr/libexec/PlistBuddy -c 'Set:CFBundleIdentifier "'${BundleID}'"' ${outpath}/Info.plist /usr/libexec/PlistBuddy -c 'Set:CFBundleDisplayName '"${BundleNAME}"'' ${outpath}/Info.plist /usr/libexec/PlistBuddy -c 'Set:CFBundleName '"${BundleNAME}"'' ${outpath}/Info.plist cd ${outpath} xcodebuild clean -alltargets echo $PATH /opt/homebrew/bin/hero-pack -config ${WORKSPACE}/iOS_Config/JP/${JOB_BASE_NAME}/packConfig.json #xcodebuild archive -project Unity-iPhone.xcodeproj -scheme Unity-iPhone -sdk iphoneos -configuration Debug -archivePath ${WORKSPACE}/build/IPA.xcarchive #xcodebuild -exportArchive -archivePath ${WORKSPACE}/build/IPA.xcarchive -exportPath ${WORKSPACE}/build/ipa -exportOptionsPlist /Users/pandora/Desktop/ExportOptions.plist ''' } } stage('post process') { steps { sh label: '', script:''' cd ${WORKSPACE} python3 ./build_ci/cache_files.py ${WORKSPACE} pandora_cli_proj/pandora/ProjectSettings/ProjectSettings.asset tmp/orgin/ProjectSettings.asset tmp/cache/ProjectSettings.asset true ''' } } stage('CopyIpa') { steps { sh label: '', script:''' DistOutputPath=${DistOutputPath}/${JOB_BASE_NAME} echo "$DistOutputPath" cd ${DistOutputPath} latest_folder=$(ls -t1 | head -n1) if [ ! -f "${DistOutputPath}/${latest_folder}/${BundleNAME}.ipa" ]; then echo "dev文件不存在" exit 1 fi cp -n "${DistOutputPath}/${latest_folder}/${BundleNAME}.ipa" "/Volumes/volume1/download/DownloadAPK/JP/${build_file_name}_dev.ipa" if [ ! -f "${DistOutputPath}/${latest_folder}/dis/${BundleNAME}.ipa" ]; then echo "dis文件不存在" exit 1 fi cp -n "${DistOutputPath}/${latest_folder}/dis/${BundleNAME}.ipa" "/Volumes/volume1/download/DownloadAPK/JP/${build_file_name}_dis.ipa" ''' } } } post { success { wrap([$class: 'BuildUser']) { script { env.buildUser = "${env.BUILD_USER}" } buildName "#${env.BUILD_NUMBER} ---> ${version}" buildDescription "点击下载: pandora_${version}_dev\n \ 点击下载: pandora_${version}_dev" } //sh label: '', script: """sh ${env.u2china_share_proj}/JenkinsFile/feishu_buildPackage.sh ${buildUser} ${appVersion} SUCCESS ${env.JOB_NAME} apk""" sh label: '', script:''' curl -X POST -H "Content-Type: application/json" -d \ '{ "msg_type": "interactive", "card": { "elements": [{ "tag": "div", "text": { "content": "构建者:admin", "tag": "lark_md" } }, { "tag": "div", "text": { "content": "分支:'$Branch'", "tag": "lark_md" } }, { "actions": [{ "tag": "button", "text": { "content": "'$build_file_name'_dev.ipa", "tag": "lark_md" }, "url": "http://10.0.22.152:8082/DownloadAPk/JP/'$build_file_name'_dev.ipa", "type": "default", "value": {} }], "tag": "action" }, { "actions": [{ "tag": "button", "text": { "content": "'$build_file_name'_dis.ipa", "tag": "lark_md" }, "url": "http://10.0.22.152:8082/DownloadAPk/JP/'$build_file_name'_dis.ipa", "type": "default", "value": {} }], "tag": "action" }], "header": { "title": { "content": "'$config_flag'-'$mode'", "tag": "plain_text" } } } } ' \ https://open.feishu.cn/open-apis/bot/v2/hook/8d1b6a92-fd8c-4c58-9e81-b2912ee1a641 ''' } failure { wrap([$class: 'BuildUser']) { script { env.buildUser = "${env.BUILD_USER}" } } //sh label: '', script: """sh ${env.u2china_share_proj}/JenkinsFile/feishu_buildPackage.sh ${buildUser} ${appVersion} FAILURE ${env.JOB_NAME} apk""" echo "FAILURE" } } }