jenkins 的安装, 自动部署的配置就不一一说了。。网上都有一大堆;
因为是在windows上部署,贴一下windows shell 命令就好了; 我也没搞懂 为什么用.net core来写 项目还得在windows上跑 部署在iis上 还连sql server数据库。。。吐槽一波
C:WindowsSystem32inetsrvappcmd.exe stop site "abc"
taskkill /im dotnet.exe /f
rd /s /q G:jenkins_publishxxxxx
cd srcxxxxx
dotnet publish -o G:jenkins_publishxxxxx
cd .... est123.Tests
dotnet test --test-adapter-path:. -l:xunit
C:WindowsSystem32inetsrvappcmd.exe start site "abc"
备注:因为是在iis上部署,在构建的时候,iis占用了发布文件, 会copy不过去; 所以蛋痛的先把站点abc给停了。。。
遇到了几个问题;
1. dotnet test -l 生成的是trx文件; 这个问题 jenkins识别不了;
在Stack Overflow上找到解决的方法:
https://stackoverflow.com/questions/49026252/how-can-i-use-xunit-net-core-test-results-in-jenkins
主要是用XunitXml.TestLogger 这个 自定义适配器;
MSTest的 convert没有实现;不知道是否能解决问题;
2.
Pattern 这个选项其实是给jenkins指定去找测试报告文件的通配符; java的工具 .net出身的还是有点蒙;