ionic3在jenkins中打包

需注意:

ionic 工程在jenkins中打包。

在svn中不要上传node_moudules文件夹,通过cpnm install --sava安装命令

现附上项目例子打包:

androidPath="${WORKSPACE}/platforms/android"
echo "构建开始"
cd ${WORKSPACE}
cnpm install --save 
# 混淆压缩开始
cnpm install gulp-uglify --save-dev
#cnpm install gulp-clean-css --save-dev
#cnpm install gulp-htmlmin --save-dev
cnpm install --save
cnpm install gulp-ngmin --save-dev 
cnpm install gulp-ng-annotate --save-dev
sed -i "s/enableGulp = false/enableGulp = true/g" gulpfile.js
/opt/node-v8.9.3/bin/gulp min
#混淆压缩结束
##版本号最后一位改为构建号。#停用
###sed -i "s/12345\"/${BUILD_NUMBER}\"/g" config.xml

#Android内部版本号android-versionCode和iOS的ios-CFBundleVersion设置为${BUILD_NUMBER}
sed -i "s/android-versionCode=\"12345\"/android-versionCode=\"${BUILD_NUMBER}\"/g" config.xml

chmod -R 755 ${WORKSPACE}/hooks/after_prepare/

ionic cordova build android --release --prod --device
find ${WORKSPACE} -maxdepth 1 -name '*.apk' -type f -print -exec rm -rf {} \;
\cp -f ${androidPath}/build/outputs/apk/android-release.apk ${WORKSPACE}/${JOB_NAME}_${BUILD_NUMBER}_release.apk
#用于上传到服务器下载
##\cp -f ${androidPath}/build/outputs/apk/android-release.apk ${WORKSPACE}/android-release.apk

#用360加固保加固 用法:http://jiagu.360.cn/qcms/help.html#!id=164
cd /opt/360jiagu
java/bin/java -jar jiagu.jar –login [email protected] syni5566
java/bin/java -jar jiagu.jar -jiagu ${WORKSPACE}/${JOB_NAME}_${BUILD_NUMBER}_release.apk ${WORKSPACE} -autosign
#重命名加固完成的apk
cd ${WORKSPACE}
rename ${JOB_NAME}_${BUILD_NUMBER}_release_*_jiagu_sign.apk ${JOB_NAME}_${BUILD_NUMBER}_release_jiagu.apk ${JOB_NAME}_${BUILD_NUMBER}_release_*_jiagu_sign.apk
#加固完成删除未加固的apk
rm -f ${WORKSPACE}/${JOB_NAME}_${BUILD_NUMBER}_release.apk

 

你可能感兴趣的:(前端)