. net Core项目的GitLab CI测试阶段失败



我的GitLab CI遇到了麻烦。我的测试阶段的预期工作流程是:

<
  • 获取变化/gh>
  • 查看
  • <
  • 下载工件/gh>
  • 运行dotnet test
  • <
  • 上传工件/gh>

当前的工作流是:

<
  • 获取变化/gh>
  • 检查出(删除所有bin/obj文件夹)
  • 上传工件->由于我的test-results.xml文件
  • 不存在,这一行失败。

我的解决方案是这样的:
——yml文件
——MyApp
——MyApp。测试

我的gitlab-runner的版本是12.4.1,我在Windows环境下使用shell执行器。

请在我的yml文件下面找到:

image: mcr.microsoft.com/dotnet/core/sdk:3.1
variables:
EXE_RELEASE_FOLDER: 'Oncolin.UI.DesktopbinRelease'
# the folder inside the deploy folder 
DEPLOY_FOLDER_APP: 'Oncolin.UI.DesktopBuilds'
CONFIGURATION: 'release'
#NUGET_PATH: 'C:NuGetnuget.exe'
#MSBUILD_PATH: 'C:Program Files (x86)Microsoft Visual Studio2019EnterpriseMSBuildCurrentBinMSBuild.exe'
#MSTEST_PATH: 'C:Program Files (x86)Microsoft Visual Studio2017EnterpriseCommon7IDEMSTest.exe'
NUNIT_PATH: '.packagesNUnit.ConsoleRunner.3.9.0toolsnunit3-console.exe'
SOLUTION: 'Oncolin.sln'
stages:
- build
- test
build:
stage: build
tags:
- windows
script:
- '& nuget restore' # restore Nuget dependencies
- '& dotnet restore'
- '& SonarScanner.MSBuild.exe begin /k:Oncolin /d:sonar.host.url=https://docker:10500 '
- '& dotnet build -c release'
- '& "$env:MSBUILD_PATH" "$env:SOLUTION" /t:Build /p:Configuration=Release' # build the project
- '& SonarScanner.MSBuild.exe end'
artifacts:
expire_in: 1 week # save gitlab server space, we copy the files we need to deploy folder later on
paths:
- '$env:EXE_RELEASE_FOLDER*' # saving exe to copy to deploy folder
- 'RNC.RULES.QUALITY.TESTS*' # saving entire Test project so NUnit can run tests 
- 'RNC.MODEL.TNM.TESTS*' # saving entire Test project so NUnit can run tests 
- 'Oncolin.Model.Tests*' # saving entire Test project so NUnit can run tests 

test:
stage: test
tags:
- windows
allow_failure: false
script:
- '& dotnet test --test-adapter-path:. --logger:"junit;LogFilePath=$CI_PROJECT_DIRartifacts{assembly}-test-result.xml;MethodFormat=Class;FailureBodyFormat=Verbose"' 
artifacts:
expire_in: 1 week # save gitlab server space, we copy the files we need to deploy folder later on
when: always
paths:
- $CI_PROJECT_DIRartifacts*test-result.xml
reports:
junit:
- $CI_PROJECT_DIRartifacts*test-result.xml
dependencies:
- build

谁能解释一下为什么下载和dotnet测试步骤被跳过?我希望我提供了足够的信息。

提前感谢。

问题来自声纳扫描仪。即使我使用。net Core声纳扫描仪,我在测试阶段也会遇到同样的问题。
我不知道为什么,我已经浪费了太多的时间去调查了。

我通过创建一个专门用于运行声纳的新阶段并在测试阶段之后运行它来解决这个问题。

最新更新