在jenkins中实用shell
Posted wzj_what_why_how
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了在jenkins中实用shell相关的知识,希望对你有一定的参考价值。
在jenkiins中配置shell脚本,对需要打包的项目做一下特定的配置和修改
代码:
echo "$android_HOME" >> local.properties
if [[ $DEBUG_ENV == true ]] ; then
sed -i '' 's/public final static boolean sIsDebug = false;/public final static boolean sIsDebug = true;/g' base/src/main/java/com/base/api/Constants.java
echo "build debug env"
else
sed -i '' 's/public final static boolean sIsDebug = true;/public final static boolean sIsDebug = false;/g' base/src/main/java/com/base/api/Constants.java
echo "build release env"
fi
if [[ $ENABLE_VIN_CHECK == true ]] ; then
sed -i '' 's/public final static boolean ENABLE_CHECK_VIN = false;/public final static boolean ENABLE_CHECK_VIN = true;/g' base/src/main/java/com/base/api/Constants.java
else
sed -i '' 's/public final static boolean ENABLE_CHECK_VIN = true;/public final static boolean ENABLE_CHECK_VIN = false;/g' base/src/main/java/com/base/api/Constants.java
fi
代码:
cp -rf ./"agconnect-services_beta.json" ./app/"agconnect-services.json"
if [[ $LOCAL_LUA == true ]] ; then
sed -i '' 's/private static final boolean IS_LOCAL_TEST = false;/private static final boolean IS_LOCAL_TEST = true;/g' core/src/main/java/com/core/lua/LuaManager.java
echo "build debug env"
else
sed -i '' 's/private static final boolean IS_LOCAL_TEST = true;/private static final boolean IS_LOCAL_TEST = false;/g' core/src/main/java/com/core/lua/LuaManager.java
echo "build release env"
fi
代码:
version=${BUILD_DISPLAY_NAME}
jobname="Beta版本"
changetitle=${CHANGE_TITLE}
svnrevision=${SVN_REVISION}
temp_product_type={$productType}
new_filename=cartect_pro_{$productType}_${SVN_REVISION}
if [[ ${DEBUG_ENV} == true ]] ; then
jobname="${jobname}_测试环境"
new_filename="${new_filename}_TestServer"
plat_id=10
else
jobname="${jobname}_正式环境"
new_filename="${new_filename}_OnlineServer"
plat_id=12
fi
if [[ ${productType} == "assemblebetaRelease" ]] ; then
jobname="${jobname}_Release"
temp_product_type="release"
plat_id=$[$plat_id+1]
else
jobname="${jobname}_Debug"
temp_product_type="debug"
fi
mv app/build/outputs/apk/beta/${temp_product_type}/app-beta-${temp_product_type}.apk app/build/outputs/apk/beta/${temp_product_type}/a.apk
其他:
以上是关于在jenkins中实用shell的主要内容,如果未能解决你的问题,请参考以下文章
Linux 中实用的 4种 shell 脚本查看网站是否正常
利用jenkins自由风格用shell脚本进行所有项目发版(java项目)