Jenkins 打包 Android

zyygive 2020-06-09

echo "======building version======";
$versionDate=Get-Date -Format ‘yyyyMMddHHmmss‘;
echo "v$versionDate";

$appPublishPath="H:\devops\live4it";

echo "======svn change trigger======";

echo "======cd Live4It dir======";
pushd H:\SVNCode\MobileApp\CTdevNew\Live4It;

echo "======svn update======";
svn update;
echo "svn update success======";

echo "======begin publish======";
cd android;
./gradlew assembleRelease -console plain;
echo "======publish success======";

echo "======list apks======";
cd .\app\build\outputs\apk\release;
ls;

echo "======copy apk======";
if(Test-Path $appPublishPath){}
else{
  mkdir $appPublishPath;
}
Copy-Item ./app-release.apk $appPublishPath –recurse;
echo "======copy success======";

echo "======read version======";
$appconfig=(Get-Content H:\SVNCode\MobileApp\CTdevNew\Live4It\src\utils\appconfig.js);
$ret=[regex]::Matches($appconfig,‘var\s+appInfo\s*=\s*\{"AppVersion"\s*:\s*"(?<version>.*?)"‘);
$version=$ret.Groups[$ret.Groups.length-1].Value;
echo "======read success======";

echo "======rename apk name======";
pushd $appPublishPath;
Rename-Item ./app-release.apk "Live4It.$version.$versionDate.apk";
echo "======rename success======";

echo "======success======";

相关推荐