Mac配置jenkinsssssss

1.安装 brew install jenkins
2.启动 iTerm jenkins
3.配置 创建管理员登陆后 系统管理->节点管理->新建节点
配置远程工作目录、标签,启动方式选择通过Java web启动代理
4.新建任务
任务配置里,限制项目的运行节点选择刚创建的节点
参数化构建过程添加打包需要的参数,可以安装插件构建成功后保存参数
增加构建步骤选择执行shell,脚本参考

projectPath=""
packageUrl=""
configTemplates=""
resPath=""
scenePath=""
buildPath=""
jsbUrl=$buildPath"/jsb-default"
configPath=""
asProjectPath=""
outputsPath=$asProjectPath/app/build/outputs/apk
releasePath=$outputsPath/release
debugPath=$outputsPath/debug


cd $projectPath
rm -rf $projectPath/temp/*
git checkout jl-master
if [ $? -ne 0 ];then
 	exit 1
 fi
git pull
if [ $? -ne 0 ];then
	exit 1
 fi
cp -f $configTemplates/config.js $projectPath/assets/script/common/config/config.js
/Applications/CocosCreator.app/Contents/MacOS/CocosCreator --path $projectPath --build "configPath=$configPath"
if [ $? -ne 0 ];then
	exit 1
fi

sh /Users/ids/develope/shell/PNGCompress/PNGCompress $resPath
if [ $? -ne 0 ];then
	exit 1
fi
/usr/local/bin/node /Users/ids/develope/NODEJS/workspace/version_generator.js -v $remoteVersion -u $packageUrl -s $jsbUrl -d $projectPath/assets
if [ $? -ne 0 ];then
	exit 1
fi
cp -f assets/project.manifest $resPath/project.manifest
cd $jsbUrl
cp -f $projectPath/assets/project.manifest project.manifest
cp -f $projectPath/assets/version.manifest version.manifest
zip -r test_ver_$remoteVersion.zip res src project.manifest version.manifest
rm -f project.manifest
rm -f version.manifest
mv test_ver_$remoteVersion.zip $projectPath/packVersion
#可以只打更新包直接上传到服务器
cd $asProjectPath
if [ $BUILD_TYPE = "Release" ];then
	./gradlew assembleRelease
elif [ $BUILD_TYPE = "Debug" ];then
	./gradlew assembleDebug
fi

if [ $? -ne 0 ];then
	exit 1
fi
#upload apk
...

ios参考

TIME=`date +%Y-%m-%d-%H-%M-%S`
cd $xcodeProjectPath
if [ $BUILD_TYPE = "Release" ];then
	xcodebuild archive -scheme $scheme -configuration Release -archivePath $ARCHIVE_PATH
elif [ $BUILD_TYPE = "Debug" ];then
	xcodebuild archive -scheme $scheme -configuration Debug -archivePath $ARCHIVE_PATH
fi

if [ $? -ne 0 ];then
	exit 1
fi

ipaPath=$outputsPath/$scheme-$TIME

mkdir $ipaPath

xcodebuild -exportArchive -archivePath $ARCHIVE_PATH -exportPath $ipaPath -exportOptionsPlist $OPT_PLIST_PATH

if [ $? -ne 0 ];then
	exit 1
fi

rm -rf build

ipa导出用到plist

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC \"-//Apple//DTD PLIST 1.0//EN\" \"http://www.apple.com/DTDs/PropertyList-1.0.dtd\">
<plist version="1.0">
<dict>
	<key>teamID</key>
	<string>teamID</string>
	<key>method</key>
	<string>development</string>
</dict>
</plist>

图片压缩
brew install pngquant
PNGCompress.zip (2.9 KB)
实在懒得打字了…:sweat:

1赞