GitLab CI和MsBuild(带测试)

Jür*_*ock 17 continuous-integration gitlab gitlab-ci

我正在使用GitLab将我的svn repsitories迁移到git.

现在我已经看到有一个与GitLab CI的持续集成实现,只是想尝试一下.

我已经安装并配置了Runner,但Gitlab抱怨我没有.gitlab-ci.yml文件.

我已经使用TeamCity进行持续集成,所以我不想花太多精力编写构建脚本.

任何人都可以告诉我在哪里可以找到一个基本的gitlab-ci.yml文件基本示例,基本上只是构建我的解决方案并运行所有测试(MSTests)?

Jür*_*ock 23

显然没有简单的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
Run Code Online (Sandbox Code Playgroud)

弄清楚要运行哪些测试有点棘手.我的惯例是每个项目都有一个文件夹测试,其中测试项目以模式MyProject.Core.Tests命名(对于一个名为MyProject.Core的项目)

就像对gitlab-ci的第一反馈一样

我喜欢简单和源代码控制集成.但是我希望能够在执行之前修改脚本(特别是在更改脚本时),但我可以成像以重新运行特定的提交并注入变量或更改脚本(我可以使用teamcity执行此操作).或者甚至忽略失败的测试并再次重新运行脚本(我使用teamcity做了很多).我知道gitlab-ci对我的测试一无所知我只有一个返回错误代码的命令行.