ciricihq / gitlab-sonar-scanner

This project is no longer maintained
GNU General Public License v3.0
80 stars 62 forks source link

Unexpected external job to the pipeline #45

Open candidoma opened 5 years ago

candidoma commented 5 years ago

Hi all, when i run sonarqube analysis on master branch i see, at the end of the pipeline, an unexpected job.

image

How i can remove it?

This not happens when use another branch, also with publishing enabled.

This is my yaml gitlab file

.quality_variables: &quality_variables
  SONAR_URL: https://xxxxxxxxxxxxxx

.quality_template: &quality_template
  stage: quality
  image: ciricihq/gitlab-sonar-scanner
  <<: *runner
  dependencies:
    - npm:test
  cache: {}
  before_script:
    - echo "sonar.login=${SONAR_TOKEN}" >> sonar-project.properties
  script: 
    - |
      gitlab-sonar-scanner \
      -Dsonar.gitlab.project_id=$CI_PROJECT_ID \
      -Dsonar.gitlab.user_token=$GITLAB_TOKEN \
      -Dsonar.gitlab.commit_sha=$CI_COMMIT_SHA \
      -Dsonar.gitlab.ref_name=$CI_COMMIT_REF_NAME
  except:
    variables:
      - $SKIP_QUALITY == "true"

quality:preview:
  <<: *quality_template
  variables:
    <<: *quality_variables
    SONAR_ANALYSIS_MODE: "preview"
  only:
    refs:
      - /^epic\/*/
      - /^hotfix\/*/
      - /^feature\/*/
      - test

quality:publish:
  <<: *quality_template
  variables:
    <<: *quality_variables
    SONAR_ANALYSIS_MODE: "publish"
  only:
    refs:
      - master

Regards

kamihouse commented 4 years ago

I have the same issue, but adding the "quality" stage as "external".
@Zero-2 Can you understand and solve your issue?

Captura de Tela 2019-10-02 às 15 29 46
sonarqube:
  image: ciricihq/gitlab-sonar-scanner:latest
  stage: Quality
  variables:
    SONAR_URL: "http://abc.xyz/"
    SONAR_ANALYSIS_MODE: "publish"
  script:
    - gitlab-sonar-scanner
      -Dsonar.host.url=${SONAR_URL}
      -Dsonar.projectKey=${CI_PROJECT_NAME}
      -Dsonar.projectName=${CI_PROJECT_NAME}
      -Dsonar.projectVersion=${CI_COMMIT_TAG}
      -Dsonar.links.homepage=${CI_PROJECT_URL}
      -Dsonar.links.ci=${CI_PROJECT_URL}/pipelines
      -Dsonar.links.scm=${CI_REPOSITORY_URL}
      -Dsonar.projectBaseDir=$(pwd)
      -Dsonar.sources=app
      -Dsonar.sourceEncoding=UTF-8
      -Dsonar.exclusions=app/Console/**,app/Exceptions/**
      -Dsonar.gitlab.project_id=${CI_PROJECT_ID}
      -Dsonar.gitlab.commit_sha=${CI_COMMIT_SHA}
      -Dsonar.gitlab.ref_name=${CI_COMMIT_REF_NAME}
      -Dsonar.php.tests.reportPath=${REPORT_PATH}/logfile.xml
      -Dsonar.php.coverage.reportPaths=${REPORT_PATH}/coverage.xml
  except:
    - /^hotfix.*$/i
  allow_failure: true
kamihouse commented 4 years ago

@Zero-2 I found a way around this problem.

Do not enter the property SONAR_ANALYSIS_MODE (~preview~ now is issues nor publish)

PS: However this does not send the review for SonarQube =(

Captura de Tela 2019-10-04 às 11 29 17
sonarqube:
  image: ciricihq/gitlab-sonar-scanner:latest
  stage: Quality
  variables:
    SONAR_URL: "http://abc.xyz/"
  script:
    - ...