Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
2.9k views
in Technique[技术] by (71.8m points)

.net core - GitLab Runner stopping after `dotnet restore` or `dotnet test`

I am new to CI and tried to add the following yaml to our project.

image: microsoft/dotnet:latest

stages:
  - test

test: 
  stage: test
  before_script:
    - 'echo Stage - Test started'
    - 'dotnet tool install dotnet-reportgenerator-globaltool --tool-path tools'
  script:  
    - 'cd "./My Project"'  
    - 'dotnet test --settings:./Settings/CodeCoverage.runsettings --collect:"XPlat Code Coverage"'
    - './tools/reportgenerator "-reports:./Tests/*/TestResults/*/coverage.cobertura.xml" "-targetdir:Reports_Coverage" -reportTypes:TextSummary'
    - 'cat ./Reports_Coverage/Summary.txt'
  after_script:
    - 'echo Stage - Test finished'

On the job I get the following output:

Running with gitlab-runner 13.7.0 (943fc252) on ***
Resolving secrets
Preparing the "kubernetes" executor
Using Kubernetes namespace: gitlab-pipeline
Using Kubernetes executor with image microsoft/dotnet:latest ...
Preparing environment
Running on*** via ***...
Getting source from Git repository
Fetching changes with git depth set to 50...
Initialized empty Git repository in /builds/***/.git/
Created fresh repository.
Checking out 07e98444 as ***...
Skipping Git submodules setup
Executing "step_script" stage of the job script
$ echo Stage - Test started
Stage - Test started
$ dotnet tool install dotnet-reportgenerator-globaltool --tool-path tools
You can invoke the tool using the following command: reportgenerator
Tool 'dotnet-reportgenerator-globaltool' (version '4.8.4') was successfully installed.
$ cd "./My Project"
$ dotnet test --settings:./Settings/CodeCoverage.runsettings --collect:"XPlat Code Coverage"
Running after_script
Running after script...
$ echo Stage - Test finished
Stage - Test finished
Cleaning up file based variables
ERROR: Job failed: command terminated with exit code 1

I tinkered around a little bit and realized, that this minified yaml also fails:

image: microsoft/dotnet:latest

stages:
  - test

test: 
  stage: test
  before_script:
    - 'cd "./My Project"'  
    - 'dotnet restore'
  script:  
    - 'dotnet test --no-restore'

This generates an equal output, except it stops at dotnet restore. I honestly don't know what to do, since this is the most minified version of a test I found. Did I mess up something within the project, or is the problem within the GitLab Runner itself?

Project Version: .net Core App 3.1


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)
等待大神答复

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...