iOS 测试 jenkins 进行 infer 静态扫描,给工作群发送报告通知

彤彤彤彤彤 · 2021年08月23日 · 最后由 恒温 回复于 2021年10月16日 · 2391 次阅读

infer 静态代码扫描学习
https://testerhome.com/topics/30910

  1. 安装 jenkins
brew install jenkins

2.构建执行 shell,填入以下信息

project_path="/Users/xx/.jenkins/workspace/infer"
WEBHOOK_URL=xxx

cd $project_path/xx
git pull


cd $project_path/xx
git pull

#初始化
xcodebuild -workspace xx.xcworkspace -scheme xx  clean

cd $project_path
#删除上次的文件
rm -rf xcodebuild.log
rm -rf infer-out
rm -rf compile_commands.json

#执行命令
#第一步
#xcodebuild -workspace xx.xcworkspace -scheme xx -sdk iphonesimulator  -arch x86_64 COMPILER_INDEX_STORE_ENABLE=NO| tee xcodebuild.log | xcpretty -r json-compilation-database -o compile_commands.json
#第二步
infer run --keep-going  --compilation-database-escaped compile_commands.json
#生成报告
infer-explore --html


#获取当前时间
time2=$(date '+%Y%m%d_%H%M%S')
cd  $project_path/infer-out
#打包报告
tar cvf $time2.tar report.html

scp /Users/didi/Documents/didi/project/infer-out/$time2.tar  root@xx.xx.xx.xx:/usr/share/nginx/html


#登录远程服务器
ssh root@xx.xx.xx.xx "cd /usr/share/nginx/html ; tar xvf $time2.tar ;mv report.html $time2; rm -rf $time2.tar; chmod -R 777 $time2" 

url="http://xx.xx.xx.x:9999/$time2/"

BUILD_USER_RD="xx"

message="{\"text\": \"IOS静态扫描执行结束,点击${url}可查看报告,请@${BUILD_USER_RD} 关注执行结果\"}"


curl -XPOST -H "Content-Type: application/json;charset=utf-8" ${WEBHOOK_URL}  -d "${message}"

如果觉得我的文章对您有用,请随意打赏。您的支持将鼓励我继续创作!
共收到 3 条回复 时间 点赞

效果怎么样啊?期待有比较多的实践分享

恒温 回复

应该其他的用的更多一些,不过我公司所在的业务线用的这个

现在 infer 用的多么。。。

彤彤彤彤彤 infer 静态代码扫描学习 总结 中提及了此贴 08月23日 17:19
需要 登录 后方可回复, 如果你还没有账号请点击这里 注册