You are viewing a plain text version of this content. The canonical link for it is here.
Posted to gitbox@hive.apache.org by GitBox <gi...@apache.org> on 2022/08/09 14:14:47 UTC

[GitHub] [hive] zabetak commented on a diff in pull request #3254: HIVE-26196: Integrate Sonar analysis for the master branch and PRs

zabetak commented on code in PR #3254:
URL: https://github.com/apache/hive/pull/3254#discussion_r941388635


##########
Jenkinsfile:
##########
@@ -304,6 +304,53 @@ tar -xzf packaging/target/apache-hive-*-nightly-*-src.tar.gz
         }
       }
   }
+  branches['sonar'] = {
+      executorNode {
+          if(env.CHANGE_BRANCH == 'master') {
+              stage('Prepare') {
+                  loadWS();
+              }
+              stage('Sonar') {
+                  withCredentials([string(credentialsId: 'sonar', variable: 'SONAR_TOKEN')]) {
+                      sh """#!/bin/bash -e
+                      sw java 11 && . /etc/profile.d/java.sh
+                      export MAVEN_OPTS=-Xmx5G
+                      mvn org.sonarsource.scanner.maven:sonar-maven-plugin:3.9.1.2184:sonar \
+                       -Dsonar.organization=apache \
+                       -Dsonar.projectKey=apache_hive \
+                       -Dsonar.host.url=https://sonarcloud.io \
+                       -Dsonar.branch.name=${CHANGE_BRANCH} \
+                       -DskipTests -Dit.skipTests -Dmaven.javadoc.skip
+                      """
+                 }
+              }
+          } else if(env.CHANGE_ID) {
+              stage('Prepare') {
+                  loadWS();
+              }
+              stage('Sonar') {
+                  withCredentials([string(credentialsId: 'sonar', variable: 'SONAR_TOKEN')]) {
+                      sh """#!/bin/bash -e
+                      sw java 11 && . /etc/profile.d/java.sh
+                      export MAVEN_OPTS=-Xmx5G
+                      mvn org.sonarsource.scanner.maven:sonar-maven-plugin:3.9.1.2184:sonar \
+                       -Dsonar.organization=apache \
+                       -Dsonar.projectKey=apache_hive \
+                       -Dsonar.host.url=https://sonarcloud.io \
+                       -Dsonar.pullrequest.github.repository=apache/hive \
+                       -Dsonar.pullrequest.key=${CHANGE_ID} \
+                       -Dsonar.pullrequest.branch=${CHANGE_BRANCH} \
+                       -Dsonar.pullrequest.base=${CHANGE_TARGET} \
+                       -Dsonar.pullrequest.provider=GitHub \
+                       -DskipTests -Dit.skipTests -Dmaven.javadoc.skip
+                      """
+                 }

Review Comment:
   There are many similarities in this code snippet. You can probably refactor the moving part (different properties) in a variable (using the `if` branches) and call afterwards mvn.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: gitbox-unsubscribe@hive.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: gitbox-unsubscribe@hive.apache.org
For additional commands, e-mail: gitbox-help@hive.apache.org