jenkins 参数化job

/ shell / 0 条评论 / 784浏览
1. gitpath

2. sdkgit

if(gitpath.equals("WORKBENCH")){
return ["/home/yanghl/gitcode/NQMDMJail","/home/yanghl/gitcode/NQMDM"]
}else if(gitpath.equals("WORKBENCH531")){
return ["/home/yanghl/WORKBENCH531/NQMDMJail","/home/yanghl/WORKBENCH531/NQMDM531","/home/yanghl/ZR506/NQMDM","/home/yanghl/SZJY/NQMDM"]
}else if(gitpath.equals("WORKBENCH53")){
return ["/home/yanghl/WORKBENCH53/NQMDM53"]
}else{
return ["/home/yanghl/"+gitpath+"/NQMDM"]
}
3. ftppath

if(gitpath.equals("WORKBENCH531")){
   if(sdkgit.contains("ZR506")){
     return ["ZR506"]
}else if(sdkgit.contains("SZJY")){
     return ["深圳监狱"]
}else if(sdkgit.contains("Jail")){
     return ["UEMJail"]
}else{
return ["UEM5.3.1"]
}
}else if(gitpath.equals("WORKBENCH")){
if(sdkgit.contains("Jail")){
     return ["UEMJail"]
}else{
return ["123"]
}
}else if(gitpath.equals("WORKBENCH53")){
return ["UEM5.3"]
}else if(gitpath.equals("HZKJ")){
return ["杭州空军"]
}else if(gitpath.equals("JTJ77")){
return ["集团军"]
}else if(gitpath.equals("SHJT53")){
return ["三环集团53"]
}else if(gitpath.equals("XBK")){
return ["星巴克"]
}else if(gitpath.equals("SSZR")){
return ["三所准入测试"]
}else if(gitpath.equals("SZGXJ")){
return ["深圳工信局"]
}else if(gitpath.equals("ASJDS")){
return ["贵州安顺戒毒所"]
}else if(gitpath.equals("XTXMR")){
return ["夏天项目"]
}else if(gitpath.equals("DDPOC")){
return ["钉钉POC"]
}
grovvy param默认值

定时执行时,reference param没有值,需要给个默认值
手动执行没有问题上
编译脚本
#中文乱码
export LANG="en_US.UTF-8"
find $WORKSPACE -name *.apk | xargs /bin/rm -f
if [ x"$num" == x"true" ];then
   echo "add buildnumber"
   cd /home/yanghl/$gitpath
   ./num.sh /home/yanghl/$gitpath
fi
#拷贝Custom目录
if [ x"$sdkgit" == x"/home/yanghl/WORKBENCH53/NQMDM53" ];then
    rm /home/custom/Custom -rf
    if [ -d "/home/yanghl/WORKBENCH53/Custom" ]; then
         cp -rf /home/yanghl/WORKBENCH53/Custom /home/custom/
    fi
fi

if [ x"$sdkgit" == x"/home/yanghl/WORKBENCH531/NQMDM531" ];then
    rm /home/custom/Custom -rf
    if [ -d "/home/yanghl/WORKBENCH531/Custom" ]; then
         cp -rf /home/yanghl/WORKBENCH531/Custom /home/custom/
    fi
fi
#aar 编译并拷贝到android/app/libs
emmsdkworkbench $sdkgit $gitpath $baibiao

cd /home/yanghl/$gitpath
if [[ $sdkgit =~ "NQMDMJail" ]];then #监狱版
    subfix="-Jail-"
    if [ x"$gitpath" == x"WORKBENCH" ];then
          ./build.sh /home/yanghl/WORKBENCH PRISON
    else
        if [[ x"$gitpath" == x"WORKBENCH53" ]] || [[ x"$gitpath" == x"WORKBENCH531" ]];then
                ./build_all.sh /home/yanghl/$gitpath WORKBENCH $baibiao PRISON
         else
            ./build_all.sh /home/yanghl/$gitpath WORKBENCH PRISON
        fi
    fi
else     #标准版
    subfix="-Standard-"
    if [[ x"$gitpath" == x"WORKBENCH53" ]] || [[ x"$gitpath" == x"WORKBENCH531" ]];then
       ./build_all.sh /home/yanghl/$gitpath WORKBENCH $baibiao
     else
       ./build_all.sh /home/yanghl/$gitpath WORKBENCH
    fi
   
fi

apkname=`ls $WORKSPACE/build/WORKBENCH/*.apk`
if [ x"$apkname" == x"" ];then
   exit 1
fi
#重命名
apkrename="${apkname%-*}$subfix${apkname##*-}"
mv $apkname $apkrename
#上传
echo $apkrename
echo $ftppath
#ftpup $apkrename $ftppath
if [ x"$enhance" == x"false" ];then
   ftpup $apkrename $ftppath
fi
4. trigger sub project:

5. 获取git分支


jenkins java api操作