From 2e5d9d924426a06593f033c7c71d5bd222e99560 Mon Sep 17 00:00:00 2001 From: ulyasaur Date: Tue, 24 Sep 2024 11:34:19 +0300 Subject: [PATCH] add pr check --- Jenkinsfile | 26 +++++++++++++++++++++----- sonar-project.properties | 2 +- 2 files changed, 22 insertions(+), 6 deletions(-) diff --git a/Jenkinsfile b/Jenkinsfile index fc5bca5a5..edb5b7fc5 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -90,11 +90,27 @@ pipeline { } steps { echo "SonarQube Scanner installation directory: ${scannerHome}" - - sh ''' - ${scannerHome}/bin/sonar-scanner \ - -Dsonar.login=$SONAR - ''' + + script { + withEnv([ + "PR_KEY=${env.CHANGE_ID}", + "PR_BRANCH=${env.CHANGE_BRANCH}", + "PR_BASE=${env.CHANGE_TARGET}", + ]) { + if (env.PR_KEY != "null") { + sh ''' + ${scannerHome}/bin/sonar-scanner \ + -Dsonar.pullrequest.key=$PR_KEY \ + -Dsonar.pullrequest.branch=$PR_BRANCH \ + -Dsonar.pullrequest.base=$PR_BASE \ + -Dsonar.login=$SONAR + ''' + } else { + sh ''' + ${scannerHome}/bin/sonar-scanner \ + -Dsonar.login=$SONAR + ''' + } } } stage('Build image') { diff --git a/sonar-project.properties b/sonar-project.properties index 1ff51f136..e849f454b 100644 --- a/sonar-project.properties +++ b/sonar-project.properties @@ -1,7 +1,7 @@ sonar.projectKey=ita-social-projects_StreetCode_Client sonar.organization=ita-social-projects sonar.projectName=StreetCode_Client -sonar.projectDescription=Fronted app of Street Code project +sonar.projectDescription=Frontend app of Street Code project sonar.host.url=https://sonarcloud.io sonar.javascript.lcov.reportPaths=./coverage/lcov.info sonar.sources=src/