GitLab: rm: can't remove '/srv/app': No such file or directory

Hi all,

using the default template of sonarcloud in my CI/CD:

test:sonarcloud-check:
  stage: test
  variables:
    SONAR_USER_HOME: "${CI_PROJECT_DIR}/.sonar"  # Defines the location of the analysis task cache
    GIT_DEPTH: "0"  # Tells git to fetch all the branches of the project, required by the analysis task
  image:
    name: sonarsource/sonar-scanner-cli:latest
    entrypoint: [""]
  cache:
    key: "${CI_JOB_NAME}"
    paths:
      - .sonar/cache
  script:
    - sonar-scanner
  allow_failure: true
  only:
    - merge_requests
    - master
    - develop

I receive the following error:
[…]
Preparing environment

00:04

[171](https://gitlab.com/wdp-adma/adma-poc/-/jobs/690394200#L171)Running on runner-fa6cab46-project-19395361-concurrent-0 via runner-fa6cab46-srm-1597699190-4673133f...

[173](https://gitlab.com/wdp-adma/adma-poc/-/jobs/690394200#L173)Getting source from Git repository

00:06

[174](https://gitlab.com/wdp-adma/adma-poc/-/jobs/690394200#L174)$ eval "$CI_PRE_CLONE_SCRIPT"

[175](https://gitlab.com/wdp-adma/adma-poc/-/jobs/690394200#L175)Fetching changes...

[176](https://gitlab.com/wdp-adma/adma-poc/-/jobs/690394200#L176)Initialized empty Git repository in /builds/wdp-adma/adma-poc/.git/

[177](https://gitlab.com/wdp-adma/adma-poc/-/jobs/690394200#L177)Created fresh repository.

[178](https://gitlab.com/wdp-adma/adma-poc/-/jobs/690394200#L178)Checking out 888c6f2c as refs/merge-requests/52/head...

[179](https://gitlab.com/wdp-adma/adma-poc/-/jobs/690394200#L179)Skipping Git submodules setup

[181](https://gitlab.com/wdp-adma/adma-poc/-/jobs/690394200#L181)Restoring cache

00:01

[182](https://gitlab.com/wdp-adma/adma-poc/-/jobs/690394200#L182)Checking cache for test:sonarcloud-check...

[183](https://gitlab.com/wdp-adma/adma-poc/-/jobs/690394200#L183)FATAL: file does not exist

[184](https://gitlab.com/wdp-adma/adma-poc/-/jobs/690394200#L184)Failed to extract cache

[186](https://gitlab.com/wdp-adma/adma-poc/-/jobs/690394200#L186)Downloading artifacts

00:14

[187](https://gitlab.com/wdp-adma/adma-poc/-/jobs/690394200#L187)Downloading artifacts for build (690394198)...

[188](https://gitlab.com/wdp-adma/adma-poc/-/jobs/690394200#L188)Downloading artifacts from coordinator... ok id=690394198 responseStatus=200 OK token=zAdd2w27

[190](https://gitlab.com/wdp-adma/adma-poc/-/jobs/690394200#L190)Executing "step_script" stage of the job script

00:01

[191](https://gitlab.com/wdp-adma/adma-poc/-/jobs/690394200#L191)$ rm -r /srv/app

[192](https://gitlab.com/wdp-adma/adma-poc/-/jobs/690394200#L192)rm: can't remove '/srv/app': No such file or directory

[194](https://gitlab.com/wdp-adma/adma-poc/-/jobs/690394200#L194)ERROR: Job failed: exit code 1

I like to deploy laravel + vue application.

Any idea how to fix that? Thank you very much!

Locally running the project with docker works fine
docker run --rm -e SONAR_HOST_URL="https://sonarcloud.io" -v "$(pwd):/usr/src" sonarsource/sonar-scanner-cli

1 Like

Hello Simon
and welcome to SonarSource community!

When I see those logs:

[190](https://gitlab.com/wdp-adma/adma-poc/-/jobs/690394200#L190)Executing "step_script" stage of the job script
00:01
[191](https://gitlab.com/wdp-adma/adma-poc/-/jobs/690394200#L191)$ rm -r /srv/app

I believe there is something wrong with this pipeline. With the default pipeline code you quoted, the first command called on the scanner container is sonar-scanner and not some rm command.

Executing "step_script" stage of the job script 
  00:48
$ sonar-scanner

Do you know where this rm command could come from?

Best regards
Sylvain

1 Like

Dear Sylvain, thank you for the follow up. Actually I have no clue where this comes from. I use the official docker image and just the default lines as desribed above. Thought it comes from the docker image, dosen’t it?

Hello Simon
this rm command does not come from the SonarQube docker image, or at least not directly, as you can check from its code.

I tried to reproduce with this same pipeline on some sample gitlab repo and it worked ok for me. My guess is that either this pipeline for which you get this error is running some other pipeline definition file, or some script is injected in the pipeline execution path(but where?).
As next step I would check this project branch content and the sonar-project.properties file there.

1 Like

Oh… you are so right. Thank you! Topic solved and spotted the “rm -r” in a before_script…

1 Like

Glad you solved this mystery!
Thanks for letting us know.

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.