How to get the execution error result of pipeline script?

stages:
  - sonarqube-check
sonarqube-check:
  tags:
    - linux-masa-01
  stage: sonarqube-check
  image: mcr.microsoft.com/dotnet/core/sdk:latest
  variables:
    SONAR_USER_HOME: "${CI_PROJECT_DIR}/.sonar"
    GIT_DEPTH: "0"
    PROJECT_NAME: "MASA-Stack-MASA-DCC"
  script: 
    #- "sudo apt-get update"
    #- "sudo apt-get install --yes openjdk-11-jre"
    #- "dotnet tool install --global dotnet-sonarscanner"
    #- "export PATH=\"$PATH:$HOME/.dotnet/tools\""
    - "export PATH=\"$PATH:/home/gitlab-runner/.dotnet/tools\""
    - "whoami"
    - "cd ./src"
    - "ls -lh"
    - "dotnet sonarscanner begin /k:$PROJECT_NAME /d:sonar.login=\"$SONAR_TOKEN\" /d:\"sonar.host.url=$SONAR_HOST_URL\" /d:\"sonar.verbose=true\" "
    - "dotnet build"
    - "dotnet sonarscanner end /d:sonar.login=\"$SONAR_TOKEN\""
  allow_failure: true
  only:
    - main
Running with gitlab-runner 14.9.1 (bd40e3da)
  on linux-runner-test kF5CvAzT
Preparing the "docker" executor
00:17
Using Docker executor with image mcr.microsoft.com/dotnet/core/sdk:latest ...
Pulling docker image registry.gitlab.com/gitlab-org/gitlab-runner/gitlab-runner-helper:x86_64-bd40e3da ...
Using docker image sha256:8f1a156260bf1fb4870696d9639407096e813e6c71841636bb86542858d949e0 for registry.gitlab.com/gitlab-org/gitlab-runner/gitlab-runner-helper:x86_64-bd40e3da with digest registry.gitlab.com/gitlab-org/gitlab-runner/gitlab-runner-helper@sha256:44ef76816aa741e0e9ecfdb9846f864663e504f11cd751bca0c16b0c6bfb8f0f ...
Pulling docker image mcr.microsoft.com/dotnet/core/sdk:latest ...
Using docker image sha256:54be3884701390adb9d61dcc081ecc7c2be562ce8154d34fe229606494e32946 for mcr.microsoft.com/dotnet/core/sdk:latest with digest mcr.microsoft.com/dotnet/core/sdk@sha256:e427375c684b7f6f3f3c72f9473ae323d9eda684e04595a330324fe3c66483f6 ...
Preparing environment
00:02
Running on runner-kf5cvazt-project-158-concurrent-0 via gitlab-runner-linux-51-52...
Getting source from Git repository
00:02
Fetching changes...
Reinitialized existing Git repository in /builds/devops1/sonarqube/.git/
Checking out 420cf1fa as main...
Skipping Git submodules setup
Executing "step_script" stage of the job script
00:03
Using docker image sha256:54be3884701390adb9d61dcc081ecc7c2be562ce8154d34fe229606494e32946 for mcr.microsoft.com/dotnet/core/sdk:latest with digest mcr.microsoft.com/dotnet/core/sdk@sha256:e427375c684b7f6f3f3c72f9473ae323d9eda684e04595a330324fe3c66483f6 ...
$ export PATH="$PATH:/home/gitlab-runner/.dotnet/tools"
$ whoami
root
$ cd ./src
$ ls -lh
total 200K
drwxrwxrwx 5 root root 4.0K Apr 14 09:01 Biz
drwxrwxrwx 4 root root 4.0K Apr 14 09:01 Data
drwxrwxrwx 5 root root 4.0K Apr 14 09:01 Infrastructure
-rw-rw-rw- 1 root root  12K Apr 14 09:01 MASA.DCC.sln
drwxrwxrwx 7 root root 4.0K Apr 14 09:01 Model
drwxrwxrwx 4 root root 4.0K Apr 14 09:01 Service
drwxrwxrwx 3 root root 4.0K Apr 14 09:01 UI
-rw-rw-rw- 1 root root 160K Apr 14 09:01 dccd.png
-rw-rw-rw- 1 root root  489 Apr 14 09:01 nuget.config
$ dotnet sonarscanner begin /k:$PROJECT_NAME /d:sonar.login="$SONAR_TOKEN" /d:"sonar.host.url=$SONAR_HOST_URL" /d:"sonar.verbose=true"
Could not execute because the specified command or file was not found.
Possible reasons for this include:
  * You misspelled a built-in dotnet command.
  * You intended to execute a .NET Core program, but dotnet-sonarscanner does not exist.
  * You intended to run a global tool, but a dotnet-prefixed executable with this name could not be found on the PATH.
ERROR: Job failed: exit code 1

I have installed dotnet sonarscanner using the gitlab-runner user, and when I enter the linux console, I can see that dotnet sonarscanner already exists. But according to the results of the pipeline, I only see "ERROR: Job failed: exit code 1 " but don’t know why.

root@gitlab-runner-linux-51-52:/home/gitlab-runner/.dotnet/tools# pwd
/home/gitlab-runner/.dotnet/tools
root@gitlab-runner-linux-51-52:/home/gitlab-runner/.dotnet/tools# ls
dotnet-sonarscanner

I changed it to gitlab-runner --debug run again, but still didn’t get detailed results, can anyone help me?

By the way, the gitlab-runner command is run with --user gitlab-runner, but why does the result of executing whoami in the pipeline show root?