安裝jenkins
1.下載jenkins
2.下載Java環境 (環境需求)
https://www.oracle.com/java/technologies/downloads/#jdk17-windows
MSBuild 建置
安裝jenkins的MSBuild插件
設定MSBuild路徑
取得本機MSBuild.exe路徑
VS 2022 MSBuild路徑
1
C:\Program Files\Microsoft Visual Studio\2022\Professional\MSBuild\Current\Bin
[本地專案] 重建
建立Job,並設定VS專案路徑
[本地專案] 單元測試
簡單Report
Jenkins安裝NUnit plugin
下載NUnit Console
確認有安裝成功
Jenkins建立Job
選擇建立「執行 Windows 批次指令」
1
"C:\Program Files (x86)\NUnit.org\nunit-console\nunit3-console.exe" "C:\Users\User\source\repos\ConsoleApp1\UnitTestProject1\bin\Debug\UnitTestProject1.dll" -result =TestResult.xml;format=nunit2
執行後,可以看到單元測試的報表
更多Report
Jenkins安裝NUnit plugin Jenkins安裝HTML Publisher plugin Jenkins安裝Cobertura Plugin
下載 NUnit Console :https://nunit.org/download/
下載 OpenCover :https://github.com/OpenCover/opencover/releases
下載 ReportGenerator :https://github.com/danielpalme/ReportGenerator/releases
下載 OpenCoverToCoberturaConverter :https://www.nuget.org/packages/OpenCoverToCoberturaConverter 備註 :上述都直接載ZIP解壓縮以便能快速找到exe位置為主
1
2
3
"C:\Users\User\Downloads\JenkinsTool\opencover\OpenCover.Console.exe" -register:user -target:"C:\Program Files (x86)\NUnit.org\nunit-console\nunit3-console.exe" -targetargs:"C:\Users\User\source\repos\ConsoleApp1\UnitTestProject1\bin\Debug\UnitTestProject1.dll" -filter:"+[*]*" -output:Coverage.xml
"C:\Users\User\Downloads\JenkinsTool\D\net47\ReportGenerator.exe" -reports:Coverage.xml -targetDir:CodeCoverageHTML
"C:\Users\User\Downloads\JenkinsTool\opencovertocoberturaconverter\tools\OpenCoverToCoberturaConverter.exe" -input:Coverage.xml -output:Cobertura.xml -sources:C:\Users\User\source\repos\ConsoleApp1
CI 持續整合
安裝插件 Warnings Next Generation
備註
Server重啟指令-非強制重啟
1
(jenkins_url)/safeRestart
Server重啟指令-強制重啟
1
(jenkins_url)/restart