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: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to