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 16.47 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
    spec:
      inputs:
        scanner-image:
          description: The Docker image used to run [sonar-scanner](https://docs.sonarqube.org/latest/analysis/scan/sonarscanner/)
          default: registry.hub.docker.com/sonarsource/sonar-scanner-cli:latest
        host-url:
          description: SonarQube server url
          default: ''
        project-key:
          description: SonarQube Project Key (might also be set in the `sonar-project.properties` file)
          default: ''
        project-name:
          description: SonarQube Project Name (might also be set in the `sonar-project.properties` file)
          default: ''
        base-args:
          description: SonarQube [analysis arguments](https://docs.sonarqube.org/latest/analysis/analysis-parameters/)
          default: >-
            -Dsonar.links.homepage=${CI_PROJECT_URL}
            -Dsonar.links.ci=${CI_PROJECT_URL}/-/pipelines
            -Dsonar.links.issue=${CI_PROJECT_URL}/-/issues
        quality-gate-enabled:
          description: |-
            Enables SonarQube [Quality Gate](https://docs.sonarqube.org/latest/user-guide/quality-gates/) verification.
    
            _Uses `sonar.qualitygate.wait` parameter ([see doc](https://docs.sonarqube.org/latest/analysis/ci-integration-overview/#header-1))._
          type: boolean
          default: false
    ---
    workflow:
      rules:
        # prevent branch pipeline when an MR is open (prefer MR pipeline)
        - if: '$CI_COMMIT_BRANCH && $CI_OPEN_MERGE_REQUESTS'
          when: never
        - if: '$CI_COMMIT_MESSAGE =~ "/\[(ci skip|skip ci) on ([^],]*,)*tag(,[^],]*)*\]/" && $CI_COMMIT_TAG'
          when: never
        - if: '$CI_COMMIT_MESSAGE =~ "/\[(ci skip|skip ci) on ([^],]*,)*branch(,[^],]*)*\]/" && $CI_COMMIT_BRANCH'
          when: never
        - if: '$CI_COMMIT_MESSAGE =~ "/\[(ci skip|skip ci) on ([^],]*,)*mr(,[^],]*)*\]/" && $CI_MERGE_REQUEST_ID'
          when: never
        - if: '$CI_COMMIT_MESSAGE =~ "/\[(ci skip|skip ci) on ([^],]*,)*default(,[^],]*)*\]/" && $CI_COMMIT_REF_NAME =~ $CI_DEFAULT_BRANCH'
          when: never
        - if: '$CI_COMMIT_MESSAGE =~ "/\[(ci skip|skip ci) on ([^],]*,)*prod(,[^],]*)*\]/" && $CI_COMMIT_REF_NAME =~ $PROD_REF'
          when: never
        - if: '$CI_COMMIT_MESSAGE =~ "/\[(ci skip|skip ci) on ([^],]*,)*integ(,[^],]*)*\]/" && $CI_COMMIT_REF_NAME =~ $INTEG_REF'
          when: never
        - if: '$CI_COMMIT_MESSAGE =~ "/\[(ci skip|skip ci) on ([^],]*,)*dev(,[^],]*)*\]/" && $CI_COMMIT_REF_NAME !~ $PROD_REF && $CI_COMMIT_REF_NAME !~ $INTEG_REF'
          when: never
        - when: always
    
    # test job prototype: implement adaptive pipeline rules
    .test-policy:
      rules:
        # on tag: auto & failing
        - if: $CI_COMMIT_TAG