Skip to content
Snippets Groups Projects
Select Git revision
  • master default protected
  • 4
  • 4.3
  • 4.3.1
  • 4.3.0
  • 4.2
  • 4.2.4
  • 4.2.3
  • 4.2.2
9 results

gitlab-ci-sonar.yml

Blame
  • gitlab-ci-sonar.yml 12.34 KiB
    # =========================================================================================
    # Copyright (C) 2021 Orange & contributors
    #
    # This program is free software; you can redistribute it and/or modify it under the terms 
    # of the GNU Lesser General Public License as published by the Free Software Foundation; 
    # either version 3 of the License, or (at your option) any later version.
    #
    # This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
    # without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
    # See the GNU Lesser General Public License for more details.
    #
    # You should have received a copy of the GNU Lesser General Public License along with this 
    # program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth 
    # Floor, Boston, MA  02110-1301, USA.
    # =========================================================================================
    # default workflow rules: Merge Request pipelines
    workflow:
      rules:
        # prevent branch pipeline when an MR is open (prefer MR pipeline)
        - if: '$CI_COMMIT_BRANCH && $CI_OPEN_MERGE_REQUESTS'
          when: never
        - when: always
    
    # test job prototype: implement adaptive pipeline rules
    .test-policy:
      rules:
        # on tag: auto & failing
        - if: $CI_COMMIT_TAG
        # on ADAPTIVE_PIPELINE_DISABLED: auto & failing
        - if: '$ADAPTIVE_PIPELINE_DISABLED == "true"'
        # on production or integration branch(es): auto & failing
        - if: '$CI_COMMIT_REF_NAME =~ $PROD_REF || $CI_COMMIT_REF_NAME =~ $INTEG_REF'
        # early stage (dev branch, no MR): manual & non-failing
        - if: '$CI_MERGE_REQUEST_ID == null && $CI_OPEN_MERGE_REQUESTS == null'
          when: manual
          allow_failure: true
        # Draft MR: auto & non-failing
        - if: '$CI_MERGE_REQUEST_TITLE =~ /^Draft:.*/'
          allow_failure: true
        # else (Ready MR): auto & failing
        - when: on_success
    
    variables:
      # variabilized tracking image
      TBC_TRACKING_IMAGE: "$CI_REGISTRY/to-be-continuous/tools/tracking:master"
    
      # Sonar
      SONAR_SCANNER_IMAGE: sonarsource/sonar-scanner-cli:latest
    
      # Sonar base analysis default args
      # see: https://docs.sonarqube.org/latest/analysis/analysis-parameters/
      # default uses branch analysis: https://docs.sonarqube.org/latest/branches/overview/
      SONAR_BASE_ARGS: >-
        -Dsonar.projectKey=${CI_PROJECT_PATH_SLUG}
        -Dsonar.projectName=${CI_PROJECT_PATH}
        -Dsonar.projectBaseDir=.
        -Dsonar.links.homepage=${CI_PROJECT_URL}
        -Dsonar.links.ci=${CI_PROJECT_URL}/-/pipelines
        -Dsonar.links.issue=${CI_PROJECT_URL}/-/issues
    
      # Sonar GitLab plugin args
      # see: https://github.com/gabrie-allaigre/sonar-gitlab-plugin/#plugins-properties
      # -> enabled if $SONAR_GITLAB_TOKEN is set
      SONAR_GITLAB_ARGS: >-
        -Dsonar.gitlab.url=${CI_SERVER_URL}
        -Dsonar.gitlab.user_token=${SONAR_GITLAB_TOKEN}
        -Dsonar.gitlab.project_id=${CI_PROJECT_ID}
        -Dsonar.gitlab.commit_sha=${CI_COMMIT_SHA}
        -Dsonar.gitlab.ref_name=${CI_COMMIT_REF_NAME}