The GitLab pipeline (for a dotnet project) is not validated because of the error "jobs:build:artifacts:reports config contains unknown keys: cobertura". So the pipeline of course can't be triggered.
I even tried to remove the code coverage thing, but also didn't know to achieve correctly (many attemps with other errors).
When I looked in the forums, I did find and follow many links like:
- Gitlab pipeline - reports config contains unknown keys: cobertura
- https://forum.gitlab.com/t/cobertura-reports-invalidate-ci-yaml/69244/3
But both didn't work out.
This is the pipeline code is:
variables:
  OBJECTS_DIRECTORY: "obj"
  NUGET_PACKAGES_DIRECTORY: ".nuget"
  SOURCE_CODE_PATH: "$CI_PROJECT_DIR"
  SELF_CONTAINED: "false"
  BUILD_TARGET: "Release"
  DOTNET_IMAGE: mcr.microsoft.com/dotnet/core/sdk:3.1
  SKIP_TESTS: "false"
# Coverage: TBD https://gitlab.com/gitlab-org/gitlab/-/issues/217664
.dotnet.build:
  image: $DOTNET_IMAGE
  script:
    - dotnet nuget add source "$NUGET_REPO" --name gitlab --username ???? --password ???? --store-password-in-clear-text
    - dotnet restore "$SOURCE_CODE_PATH" --packages "$NUGET_PACKAGES_DIRECTORY"
    - dotnet build "$SOURCE_CODE_PATH" -c "$BUILD_TARGET" --no-restore
    - if [ "$SKIP_TESTS" = "false" ]; then dotnet test "$SOURCE_CODE_PATH" -c "$BUILD_TARGET" -p:CollectCoverage=true -p:CoverletOutputFormat=\"opencover\" --no-build --test-adapter-path:. --logger:"junit;LogFilePath=.\artifacts\test-result.xml;MethodFormat=Class;FailureBodyFormat=Verbose"; fi
    - dotnet publish "$SOURCE_CODE_PATH" -c "$BUILD_TARGET" --no-build --self-contained "$SELF_CONTAINED"
  cache:
    key: "${CI_JOB_STAGE}-${CI_COMMIT_REF_SLUG}-dotnet"
    paths:
      - "$SOURCE_CODE_PATH/$OBJECTS_DIRECTORY/project.assets.json"
      - "$SOURCE_CODE_PATH/$OBJECTS_DIRECTORY/*.csproj.nuget.*"
      - "$NUGET_PACKAGES_DIRECTORY"
    policy: pull-push
  coverage: /Total\s*\|\s*(\d+(?:\.\d+)?)/
  artifacts:
    paths:
      - '**/*test-result.xml'
      - '**/bin/'
      - '**/*coverage.opencover.xml'
      - "$SOURCE_CODE_PATH/$OBJECTS_DIRECTORY/project.assets.json"
      - "$NUGET_PACKAGES_DIRECTORY"
    reports:
      junit:
        - '**/*test-result.xml'
      cobertura:
        - '**/*coverage.opencover.xml'
.dotnet.pack:
  image: $DOTNET_IMAGE
  artifacts:
    paths:
      - '**/bin/$BUILD_TARGET/*.nupkg'
  script:
    - PACKAGE_VERSION="$VERSION"
    - if [ -n "$CI_MERGE_REQUEST_ID" ]; then PACKAGE_VERSION="${VERSION}-dev"; fi;
    - dotnet pack -p:PackageVersion="$PACKAGE_VERSION" "$SOURCE_CODE_PATH" -c "$BUILD_TARGET" --no-build --packages "$NUGET_PACKAGES_DIRECTORY"
.dotnet.push:
  image: $DOTNET_IMAGE
  script:
    - dotnet nuget add source "$NUGET_REPO" --name gitlab --username ???? --password ???? --store-password-in-clear-text
    - dotnet nuget push "**/bin/$BUILD_TARGET/*.nupkg" --source gitlab

