如何在本地使用gitlab-runner测试.NET构建?

问题描述 投票:1回答:1

我正在尝试在本地测试我的.gitlab-ci.yml文件以获取.NET项目,但是我很难这样做。为了能够在这里提出一个有用的问题,我尝试为最小的repro创建说明,假设安装了Visual Studio 2017的完全最新的Windows 10 Pro机器。

  1. 在Visual Studio中的以下位置创建一个新的.NET 4.6.2控制台应用程序“GlabTest”:c:\experiments\GlabTest
  2. 包管理器控制台:Install-Package NewtonSoft.Json
  3. Console.WriteLine(Newtonsoft.Json.JsonConvert.SerializeObject(1));是Main函数中唯一的代码行
  4. .gitlab-ci.yml文件旁边有这个内容的sln文件: variables: RELEASE_FOLDER: 'GlabTest/bin/Release' MSBUILD: 'C:\Program Files (x86)\Microsoft Visual Studio\2017\Enterprise\MSBuild\15.0\Bin\MSBuild.exe' stages: - build build_job: stage: build script: - 'nuget restore' - '& "$env:MSBUILD" GlabTest.sln /p:Configuration=Release /t:Rebuild' artifacts: paths: - '$env:RELEASE_FOLDER\'
  5. .gitignore用这个: .vs/ **/[Pp]ackages/* [Bb]in/ [Oo]bj/
  6. git initgit add .git commit -m "Weeee"
  7. 关注these instructions并下载到c:\gl\gitlab-runner-windows-amd64.exe
  8. 打开PowerShell,转到sln文件夹
  9. & 'C:\gl\gitlab-runner-windows-amd64.exe' exec shell build_job

这将吐出各种错误:

  • Since gitLab Runner 10.0 this command is marked as DEPRECATED”没有任何暗示如何从exec迁移
  • 将repo克隆到自身的子文件夹中(.../GlabTest/builds/0/project-0
  • & was unexpected at this time.”接近尾声
  • 各种输出问题,例如:最后一行是: [31;1mERROR: Job failed: exit status 255

在我深入研究“DEPRECATED”命令之前,我应该退一步问:在Windows机器上使用Powershell构建本地迭代.gitlab-ci.yml文件的推荐方法是什么?

powershell gitlab gitlab-ci gitlab-ci-runner
1个回答
1
投票

[为什么说DEPRECATED,我们应该使用什么呢?]

好吧,没有新方法可以做到这一点,it seems exec is being deprecated without a current replacement

将repo克隆到自身的子文件夹中......

不知道如何解决这个问题。

此时此刻意外

那是因为cmd是Windows上的默认shell,所以你应该这样做:

& 'C:\gl\gitlab-runner-windows-amd64.exe' exec shell build_job --shell powershell

(注意最后的--shell powershell。)

各种输出问题

不知道那里发生了什么。可能你的终端与gitlab-runner.exe尝试着色输出的方式不兼容?

© www.soinside.com 2019 - 2024. All rights reserved.