【无标题】

jenkins创建任务

自动化编译安卓源码

在这里插入图片描述
配置
在这里插入图片描述
在这里插入图片描述
在这里插入图片描述
在这里插入图片描述

在这里插入图片描述
在这里插入图片描述

在这里插入图片描述

在这里插入图片描述

#!/bin/bash

# @By Sven

# Set recipient list.
echo "CUSTOM_RECIPIENT_EMAIL_LIST=${RECIPIENT_LIST}" > local_properties.txt

# Step1 Check the project related env variables.
ENV_SUBDIR=""
VER_SUBDIR_SUFFIX=""
# Use to Build smt project.
BUILD_SMT=""
BRANCH_DIM=""
OTA_DIFF_DIR="test"
OTA_DIFF_PATH=""

echo "=============custom define===================="
echo "BRANCH_VER: ${BRANCH_VER}"
echo "SHA04: ${SHA04}"
echo "BUILD_ENV: ${BUILD_ENV}"
echo "COMPILE_VERSION: ${COMPILE_VERSION}"
echo "ROM_VER: ${ROM_VER}"
echo "APP_VER: ${APP_VER}"
echo "DEVICE_TYPE: ${DEVICE_TYPE}"
echo "CV_FACE_VER: ${CV_FACE_VER}"
echo "BUILD_APK_PATH: ${BUILD_APK_PATH}"

#######Display build timestamp######################
echo "##########################  build time  #######################"
timestamp=`date`
echo "DATE: $(date)  ${timestamp}"
echo "##########################  time end ##########################"


function displayBuildInfo()
{
cat << EOF >> local_properties.txt
  CUSTOM_CONTENT= \
  <li>构建环境:${BUILD_ENV}</li> \
  <li>构建版本: ${ROM_VER}_${APP_VER}</li>
EOF
}

function buildErrorProcess()
{
    # Clean the prop file.
    echo "CUSTOM_RECIPIENT_EMAIL_LIST=djzheng@wisepool.com.cn" > local_properties.txt
    displayBuildInfo
    sync
    exit 1
}

displayBuildInfo

readonly OTA_DIFF_TARGET_FILES_TOP_DIR="${PWD}-base"
readonly BRANCH_NAME_TEST="SHA_mtk8167s_test"
readonly BRANCH_NAME_UAT="SHA_mtk8167s_test"
readonly BRANCH_NAME_FULLTEST="SHA_mtk8167s_fulltest"
readonly BRANCH_NAME_PRODUCT="SHA_mtk8167s_product"
readonly BRANCH_NAME_RAM2G_TEST="LL_sha_mtk8167s_ram2g"
readonly BRANCH_NAME_RAM2G_UAT="LL_sha_mtk8167s_ram2g"
readonly BRANCH_NAME_RAM2G_PRODUCT="SHA_mtk8167s_ram2g_product"
readonly BRANCH_NAME_RAM2G_SMT="SHA_mtk8167s_ram2g_product"
readonly BRANCH_NAME_RAM2G_HOSPITAL="LL_sha_mtk8167s_ram2g_hospital"

readonly BRANCH_NAME_RAM4G_HOSPITAL="master"

whoami
who=`whoami`
echo "==>who:${who}"
export USE_CCACHE=1
ccache -s

test -z ${ROM_VER} && "Error: ROM_VER is null. please set it, such as: V1.0.1"

test -z ${APP_VER} && "Error: APP_VER is null, please set it, such as:VAPP1.0.1"

temp_str=`echo $ROM_VER|cut -c1`
if [ ${temp_str} != "V" ]; then
    echo "ROM_VER=${ROM_VER} is incorrect format."

    buildErrorProcess
fi

temp_str=`echo $APP_VER|cut -c1-4`
if [ ${temp_str} != "VAPP" ]; then
    echo "APP_VER=${APP_VER} is incorrect format."
    buildErrorProcess
fi

##rk3399 
# Check compile release env for hospital device.
if [ ${DEVICE_TYPE} = "longhua" ]; then
if [ ${BUILD_ENV} = "dev" ]; then
    ENV_SUBDIR="dev_version"
    VER_SUBDIR_SUFFIX=".dev"
    OTA_DIFF_DIR="dev"
    BRANCH_DIM=${BRANCH_NAME_RAM2G_HOSPITAL}
elif [ "${BUILD_ENV}" = "uat" ]; then
    ENV_SUBDIR="uat_version"
    VER_SUBDIR_SUFFIX=".uat"
    OTA_DIFF_DIR="uat"
    BRANCH_DIM=${BRANCH_NAME_RAM2G_HOSPITAL}
elif [ "${BUILD_ENV}" = "prod" ]; then
    ENV_SUBDIR="prod_version"
    OTA_DIFF_DIR="sit"
    BRANCH_DIM=${BRANCH_NAME_RAM2G_HOSPITAL}
elif [ "${BUILD_ENV}" = "sit" ]; then
    ENV_SUBDIR="sit_version"
    OTA_DIFF_DIR="sit"
    BRANCH_DIM=${BRANCH_NAME_RAM2G_HOSPITAL}    
elif [ "${BUILD_ENV}" = "smt" ]; then
    ENV_SUBDIR="smt_version"
    BRANCH_DIM=${BRANCH_NAME_RAM2G_HOSPITAL}
    BUILD_SMT="--smt"
else
    echo "The correct rk3399 longhua environment was not specified!"
    buildErrorProcess
fi
# Type next
elif [ ${DEVICE_TYPE} = "hospital" ]; then
if [ ${BUILD_ENV} = "dev" ]; then
    ENV_SUBDIR="dev_version"
    VER_SUBDIR_SUFFIX=".dev"
    OTA_DIFF_DIR="dev"
    BRANCH_DIM=${BRANCH_NAME_RAM2G_HOSPITAL}
elif [ "${BUILD_ENV}" = "uat" ]; then
    ENV_SUBDIR="uat_version"
    VER_SUBDIR_SUFFIX=".uat"
    OTA_DIFF_DIR="uat"
    BRANCH_DIM=${BRANCH_NAME_RAM2G_HOSPITAL}
elif [ "${BUILD_ENV}" = "prod" ]; then
    ENV_SUBDIR="prod_version"
    OTA_DIFF_DIR="sit"
    BRANCH_DIM=${BRANCH_NAME_RAM2G_HOSPITAL}
elif [ "${BUILD_ENV}" = "sit" ]; then
    ENV_SUBDIR="sit_version"
    OTA_DIFF_DIR="sit"
    BRANCH_DIM=${BRANCH_NAME_RAM2G_HOSPITAL}    
elif [ "${BUILD_ENV}" = "smt" ]; then
    ENV_SUBDIR="smt_version"
    BRANCH_DIM=${BRANCH_NAME_RAM2G_HOSPITAL}
    BUILD_SMT="--smt"
else
    echo "The correct rk3399 hospital environment was not specified!"
    buildErrorProcess
fi
# Type next
elif [ ${DEVICE_TYPE} = "longhua_hospital" -o ${DEVICE_TYPE} = "localization" ]; then
if [ ${BUILD_ENV} = "dev" ]; then
    ENV_SUBDIR="dev_version"
    VER_SUBDIR_SUFFIX=".dev"
    OTA_DIFF_DIR="dev"
    BRANCH_DIM=${BRANCH_NAME_RAM2G_HOSPITAL}
elif [ "${BUILD_ENV}" = "uat" ]; then
    ENV_SUBDIR="uat_version"
    VER_SUBDIR_SUFFIX=".uat"
    OTA_DIFF_DIR="uat"
    BRANCH_DIM=${BRANCH_NAME_RAM2G_HOSPITAL}
elif [ "${BUILD_ENV}" = "prod" ]; then
    ENV_SUBDIR="prod_version"
    OTA_DIFF_DIR="sit"
    BRANCH_DIM=${BRANCH_NAME_RAM2G_HOSPITAL}
elif [ "${BUILD_ENV}" = "sit" ]; then
    ENV_SUBDIR="sit_version"
    OTA_DIFF_DIR="sit"
    BRANCH_DIM=${BRANCH_NAME_RAM2G_HOSPITAL}    
elif [ "${BUILD_ENV}" = "smt" ]; then
    ENV_SUBDIR="smt_version"
    BRANCH_DIM=${BRANCH_NAME_RAM2G_HOSPITAL}
    BUILD_SMT="--smt"
else
    echo "The correct rk3399 hospital environment was not specified!"
    buildErrorProcess
fi

fi
##enter sdk dir
#cd sdk
#git checkout master


# Check that the branch and request compilation environment are same.
#check_branch=`git name-rev --name-only HEAD | grep -E "${BRANCH_DIM}" `
#echo "==> ${check_branch}"
#if [ -z "${check_branch}" ]; then
#    echo "The project branch was not exist - [ ${BRANCH_DIM} ]"
#    buildErrorProcess
#fi

# SMT project don't build otadiff package. so we skip it.
if [ "${BUILD_ENV}"x != "smt"x ]; then
OTA_DIFF_PATH="${OTA_DIFF_TARGET_FILES_TOP_DIR}/${DEVICE_TYPE}/${OTA_DIFF_DIR}"
if [ ! -d "${OTA_DIFF_PATH}" ]; then
    echo "OTA diff path isn't found [${OTA_DIFF_PATH}]"
    echo "Please check correct ota diff directory..."
    buildErrorProcess
fi
fi

echo "OTA_DIFF_PATH: ${OTA_DIFF_PATH}"
# test
#exit 0


# Step2 Cleanup and update all project from gitlab.
./distribute --clean
if [ $? != 0 ]; then
    echo "./distribute --clean <<< ERROR >>>"
    buildErrorProcess
fi

# When execture the '--clean' after we should run the 'echo' again. otherwise willnot find the local_properties.txt.
echo "CUSTOM_RECIPIENT_EMAIL_LIST=${RECIPIENT_LIST}" > local_properties.txt
displayBuildInfo

#  Pull apk according to build environment.
# SMT env without apk.
if [ ${BUILD_ENV} != "smt" ]; then
echo "./distribute --app ${BUILD_ENV} ${BUILD_APK_PATH}"
./distribute --app ${BUILD_ENV} ${BUILD_APK_PATH}
if [ $? != 0 ]; then
    echo "./distribute --app ${BUILD_ENV} <<< ERROR >>>"
    buildErrorProcess
fi
fi

# Step3 Exector to set project version
./distribute --setversion ${ROM_VER} ${APP_VER} ${BUILD_ENV} ${DEVICE_TYPE}
exit 0

# Update cv face sdk.
if [ ! -z "${CV_FACE_VER}" ]; then
./distribute --face ${CV_FACE_VER}
fi

# ./distribute --otadiff ${target_file_dir}
# Step4 Start compiling the project.
./distribute --${COMPILE_VERSION} $BUILD_SMT
if [ $? != 0 ]; then
    echo "./distribute --${COMPILE_VERSION} $BUILD_SMT  <<< ERROR >>>"
    buildErrorProcess
fi


./distribute --otapackage
if [ $? != 0 ]; then
    echo "./distribute --otapackage  <<< ERROR >>>"
    buildErrorProcess
fi

./distribute --b
if [ $? != 0 ]; then
    echo "./distribute --b  <<< ERROR >>>"
    buildErrorProcess
fi

# Current no support make diff 
#if [ "${DEVICE_TYPE}" != "hospital" ]; then
if [ "${DEVICE_TYPE}" -ne "longhua" -o "${DEVICE_TYPE}" -ne "hospital" -o "${DEVICE_TYPE}" -ne "longhua_hospital"  -o "${DEVICE_TYPE}" -ne "localization" ]; then
#########################################################
if [ "${BUILD_ENV}"x = "prod"x ]; then
./distribute --otadiff ${OTA_DIFF_PATH}
if [ $? != 0 ]; then
    echo "./distribute --otadiff  <<< ERROR >>>"
    buildErrorProcess
fi
fi

# mark test and uat
if [ "${BUILD_ENV}" = "allow"x ]; then
#@ test
if [ "${BUILD_ENV}"x = "test"x ]; then
./distribute --otadiff ${OTA_DIFF_PATH}
if [ $? != 0 ]; then
    echo "./distribute --otadiff  <<< ERROR >>>"
    buildErrorProcess
fi
fi
# allow
fi

#@ uat
if [ "${BUILD_ENV}"x = "uat"x ]; then
./distribute --otadiff ${OTA_DIFF_PATH}
if [ $? != 0 ]; then
    echo "./distribute --otadiff  <<< ERROR >>>"
    buildErrorProcess
fi
fi
##################################################
fi # disable hospital/disable longhua/disable longhua_hospital

# Step5 Start uploading the release files to ftp server.
UPLOAD_ENV=${BUILD_ENV}
#if [ "${BUILD_ENV}" = "prod" ]; then
#   UPLOAD_ENV="product"
#fi

./upload_ftp ${UPLOAD_ENV} ${DEVICE_TYPE} ${BUILD_APK_PATH}

if [ $? = 0 ]; then
    if [ "${DEVICE_TYPE}" = "longhua" ]; then
        echo "RELEASE_SUB_PATH=${DEVICE_TYPE}_version/${ENV_SUBDIR}/${ROM_VER}_${APP_VER}${VER_SUBDIR_SUFFIX}" >> local_properties.txt
    elif [ "${DEVICE_TYPE}" = "hospital" ]; then
        echo "RELEASE_SUB_PATH=${DEVICE_TYPE}_version/${ENV_SUBDIR}/${ROM_VER}_${APP_VER}${VER_SUBDIR_SUFFIX}" >> local_properties.txt
    elif [ "${DEVICE_TYPE}" = "longhua_hospital" ]; then
        echo "RELEASE_SUB_PATH=${DEVICE_TYPE}_version/${ENV_SUBDIR}/${ROM_VER}_${APP_VER}${VER_SUBDIR_SUFFIX}" >> local_properties.txt 
    elif [ "${DEVICE_TYPE}" = "localization" ]; then
        echo "RELEASE_SUB_PATH=${DEVICE_TYPE}_version/${ENV_SUBDIR}/${ROM_VER}_${APP_VER}${VER_SUBDIR_SUFFIX}" >> local_properties.txt                
    else
        echo "RELEASE_SUB_PATH=${ENV_SUBDIR}/${ROM_VER}_${APP_VER}${VER_SUBDIR_SUFFIX}" >> local_properties.txt
    fi
else
    echo "RELEASE_SUB_PATH=null" >> local_properties.txt
fi

# Show inject env var.
cat local_properties.txt
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值