顯然沒有簡單的MSBuild例子,但這應該讓你開始:
variables:
Solution: MySolution.sln
before_script:
- "echo off"
- 'call "%VS120COMNTOOLS%\vsvars32.bat"'
# output environment variables (usefull for debugging, propably not what you want to do if your ci server is public)
- echo.
- set
- echo.
stages:
- build
- test
- deploy
build:
stage: build
script:
- echo building...
- 'msbuild.exe "%Solution%"'
except:
- tags
test:
stage: test
script:
- echo testing...
- 'msbuild.exe "%Solution%"'
- dir /s /b *.Tests.dll | findstr /r Tests\\*\\bin\\ > testcontainers.txt
- 'for /f %%f in (testcontainers.txt) do mstest.exe /testcontainer:"%%f"'
except:
- tags
deploy:
stage: deploy
script:
- echo deploying...
- 'msbuild.exe "%Solution%" /t:publish'
only:
- production
搞清楚哪些測試運行是有點棘手。我的慣例是,每個項目都有其測試項目的架構MyProject.Core.Tests命名的文件夾測試(名爲MyProject.Core項目)
正如對gitlab-CI的第一反饋
我喜歡簡單性和源代碼控制集成。但我希望能夠在執行前修改腳本(特別是在更改腳本時),但是我可以通過映像重新運行特定的提交併注入變量或更改腳本(我可以使用teamcity執行此操作)。甚至忽略一個失敗的測試並重新運行腳本(我在teamcity上做了很多)。我知道gitlab-ci不知道任何關於我的測試我只是有一個命令行返回一個錯誤代碼。
結帳https://about.gitlab.com/2015/06/08/implementing-gitlab-ci-dot-yml/ – Mutuma