cathive / concourse-sonarqube-resource

performs SonarQube analyses and checks quality gates https://concourse-ci.org/ https://sonarqube.org/
Apache License 2.0
46 stars 50 forks source link

ERROR in /opt/resource/out : line 234 with exit code 1 #59

Closed skreddy6673 closed 3 years ago

skreddy6673 commented 4 years ago

Concourse pipeline failing with following errors, Any help would be helpful.

Digest: sha256:3a273ba13f295e2d6400d89151c15390b5b129ebdb67bc65589dc57a850d5dde
Status: Downloaded newer image for cathive/concourse-sonarqube-resource@sha256:3a273ba13f295e2d6400d89151c15390b5b129ebdb67bc65589dc57a850d5dde

Successfully pulled cathive/concourse-sonarqube-resource@sha256:3a273ba13f295e2d6400d89151c15390b5b129ebdb67bc65589dc57a850d5dde.

Preparing SonarQube scanner...
ERROR in /opt/resource/out : line 234 with exit code 1
Digest: sha256:c8aff28e93d7cfddc4b975f467a52b7d7cd21d433451d52c1ea88a23d382fc9d
Status: Downloaded newer image for cathive/concourse-sonarqube-resource@sha256:c8aff28e93d7cfddc4b975f467a52b7d7cd21d433451d52c1ea88a23d382fc9d

Successfully pulled cathive/concourse-sonarqube-resource@sha256:c8aff28e93d7cfddc4b975f467a52b7d7cd21d433451d52c1ea88a23d382fc9d.

Preparing SonarQube scanner...
ERROR in /opt/resource/out : line 255 with exit code 1
Status: Downloaded newer image for cathive/concourse-sonarqube-resource@sha256:aad9ff30d95c158a86b523aac9d308d97d52956617a257be2d1019287be56a85

Successfully pulled cathive/concourse-sonarqube-resource@sha256:aad9ff30d95c158a86b523aac9d308d97d52956617a257be2d1019287be56a85.

Preparing SonarQube scanner...
ERROR in /opt/resource/out : line 234 with exit code 1
skreddy6673 commented 4 years ago

This pipeline once worked with image 0.10.0.

headcr4sh commented 4 years ago

Thanks for the bug report.

Please set the configuration parameter __debug to true and run the resource again.

The verbose output might provide some insights into this bug.

skreddy6673 commented 4 years ago

Adding _debug: true under resource didn't display any additional output.

headcr4sh commented 4 years ago

It's __debug: true (notice that there are two underscores in front of the key!!)

Should have mentioned that before. It's always a bit confusing...

skreddy6673 commented 4 years ago

Sorry got pulled into other things, @headcr4sh Actually debug option woked, my bad i didn't notice two underscores.

- name: validate-pr
  plan:
  - get: pull-request
    trigger: true
    version: every
  - get: pipeline-source
  - params:
      path: pull-request
      status: pending
    put: pull-request
  - get: scm-source
  - config:
      caches:
      - path: maven
      container_limits: {}
      image_resource:
        source:
          repository: maven
          tag: 3.6-jdk-8
        type: docker-image
      inputs:
      - name: pull-request
      - name: pipeline-source
      outputs:
      - name: sonarqube-analysis-input
      platform: linux
      run:
        args:
        - -xce
        - |
          M2_HOME="${HOME}/.m2"
          M2_CACHE="$(pwd)/maven"
          ln -s $M2_CACHE $M2_HOME
          cd pull-request
          ls
          mvn --batch-mode -s maven_settings.xml clean package
          cd ..
          cp -r pull-request/* sonarqube-analysis-input
          cd sonarqube-analysis-input
#          ls
        path: /bin/sh
    on_failure:
      params:
        comment: Maven build FAILED for this pull request
        path: pull-request
        status: failure
      put: pull-request
    task: unit-test
  - params:
      additional_properties:
        sonar.scm.disabled: true
      project_key: submissions-api
      project_path: sonarqube-analysis-input
      maven_settings_file: sonarqube-analysis-input/maven_settings.xml
      sources:
      - .
    put: code-analysis
  public: true

This is my job and after adding the maven_settings_file location path it's able to pick it up but somehow failing with following error

[ERROR] Error executing Maven.
java.io.FileNotFoundException: The specified user settings file does not exist: /tmp/build/put/sonarqube-analysis-input/sonarqube-analysis-input/maven_settings.xml

I don't know why it's looking for sonarqube-analysis-input/sonarqube-analysis-input/ at the same location twice.

xsorifc28 commented 4 years ago
  maven_settings_file: sonarqube-analysis-input/maven_settings.xml

Did you try removing sonarqube-analysis-input from above line?

skreddy6673 commented 4 years ago

@xsorifc28 I tried removing sonarqube-analysis-input and this time it is failing during Preparing SonarQube scanner itself.

+ echo 'error: Maven settings file not found: "maven_settings.xml".'
error: Maven settings file not found: "maven_settings.xml".
+ exit 1

If i don't remove this line the preparing Sonarqube step passes but fails later in execution with the error from my previous comment.

headcr4sh commented 4 years ago

Very curious. I currently don't have the time to dig further into this issue (this is an example unpaid open source project after all), but I'll try to find a solution (should be easy to find the cause of this issue, I hope) as soon as possible. Might take a week or two, though.

In the meantime... if anyone else comes up with a fix, I'll gladly accept a patch. :-)

cyclump commented 4 years ago

I was browsing the open issues because I've gone deep in the code here lately for out. I opened issue #65 without realizing this issue was opened. The workaround until it is fixed is to prefix the maven_setttings_file location with /tmp/build/put. Right before running the maven command the code cds into the maven project folder. The problem is the maven file path is relatively pathed to /tmp/build/put by concourse. Setting the maven_settings_file to an absolute path of /tmp/build/put/sonarqube-analysis-input/maven_settings.xml works around the problem but doesn't seem very concourse like.