Reports types wrong extraction values on dotnet_run_test function

Describe the bug

Reports types are extracted wrongly when the .xml reports name have different name that is expected to be. Expected: dotnet-test.opencover.xml Real report name: dotnet-test.net8.0.opencover.xml

Expected behavior

Extract correct report type.

Actual behavior

Part of the affetced code:

dotnet_run_test function:

report_type=$(echo "$report_name" | cut -d. -f2)

Actual behaviour:

export report_name=dotnet-test.net8.0.cobertura.xml
echo "$report_name" | cut -d. -f2
net8

Proposed solution:

report_type=$(echo "$report_name" | awk -F. '{print $(NF-1)}')

NF is the total number of fields, so NF-1 is the second to last.

Testing solution:

export report_name=dotnet-test.net8.0.cobertura.xml
echo "$report_name" | awk -F. '{print $(NF-1)}'
cobertura

Logs and/or screenshots

[DEBUG] Copying test report dotnet-test.junit.xml for project dir dotnet-test-dotnet-sample-UnitTest.junit.xml
[DEBUG] Copying test report dotnet-test.net8.0.cobertura.xml for project dir dotnet-test-dotnet-sample-UnitTest.net8.xml
[DEBUG] Copying test report dotnet-test.net8.0.opencover.xml for project dir dotnet-test-dotnet-sample-UnitTest.net8.xml
[DEBUG] Copying test report dotnet-test.xunit.xml for project dir dotnet-test-dotnet-sample-UnitTest.xunit.xml
......
WARNING: projects/dotnet-sample/reports/dotnet-test-*.cobertura.xml: no matching files. Ensure that the artifact path is relative to the working directory (/builds/dotnet/training-project) 

Context & Configuration

Link to line of code facing the bug

The issue was reproduced using:

  • Version of the template: 2.2.2
  • GitLab server(s): self-managed server
Edited by Gheorghi Ciochina