버전 비교

  • 이 줄이 추가되었습니다.
  • 이 줄이 삭제되었습니다.
  • 서식이 변경되었습니다.

...

  1. Jenkins에서 SonarQube 품질 게이트 실패 시 파이프라인 자동 실패 처리

    1. SonarQube 서버에서 프로젝트에 대한 웹훅을 구성합니다추가합니다.
      Image Added

    2. URL에 <yourJenkinsInstance>/sonarqube-webhook/를 입력합니다.
      Image Added

    3. Jeknins 파일에 아래와 같이 waitForQualityGate단계를 추가합니다.
      - Scripted pipeline

      코드 블럭
      node {
        stage('SonarQube analysis') {
          withSonarQubeEnv('<sonarqubeInstallation>') {
            sh 'mvn clean verify org.sonarsource.scanner.maven:sonar-maven-plugin:sonar'
          } // submitted SonarQube taskId is automatically attached to the pipeline context
        }
      }
      
      // No need to occupy a node
      
      stage("Quality Gate"){
        timeout(time: 1, unit: 'HOURS') { // Just in case something goes wrong, pipeline will be killed after a timeout
          def qg = waitForQualityGate() // Reuse taskId previously collected by withSonarQubeEnv
          if (qg.status != 'OK') {
            error "Pipeline aborted due to quality gate failure: ${qg.status}"
          }
        }
      }

  2. GitLab Merge Request에서 모든 Pipeline 성공 조건 설정

    1. GitLab 프로젝트의 Settings > General > Merge requests로 이동합니다.

    2. Merge checks 섹션에서 Pipelines must succeed를 선택합니다.
      Image Added

    3. Save changes를 클릭하여 변경 사항을 저장합니다.

  3. 품질게이트 실패 시, Jenkins 파이프라인이 실패하며 GitLab에서 Merge가 Block됩니다.



...

참고

...