hbase-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From bus...@apache.org
Subject [1/3] hbase git commit: HBASE-18467 report nightly results to devs via jira [Forced Update!]
Date Sun, 25 Feb 2018 15:45:38 GMT
Repository: hbase
Updated Branches:
  refs/heads/HBASE-15151 4d6a00c6b -> 97a3a9a31 (forced update)


HBASE-18467 report nightly results to devs via jira


Project: http://git-wip-us.apache.org/repos/asf/hbase/repo
Commit: http://git-wip-us.apache.org/repos/asf/hbase/commit/061c0138
Tree: http://git-wip-us.apache.org/repos/asf/hbase/tree/061c0138
Diff: http://git-wip-us.apache.org/repos/asf/hbase/diff/061c0138

Branch: refs/heads/HBASE-15151
Commit: 061c01389703f0a92901624e4dd36e4ac71f2386
Parents: 549a6d9
Author: Sean Busbey <busbey@apache.org>
Authored: Wed Aug 9 00:48:46 2017 -0500
Committer: Sean Busbey <busbey@apache.org>
Committed: Sun Feb 25 09:45:20 2018 -0600

----------------------------------------------------------------------
 dev-support/Jenkinsfile | 165 +++++++++++++++++++++++++++++++++++++++----
 1 file changed, 150 insertions(+), 15 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/hbase/blob/061c0138/dev-support/Jenkinsfile
----------------------------------------------------------------------
diff --git a/dev-support/Jenkinsfile b/dev-support/Jenkinsfile
index 201783b..31416dd 100644
--- a/dev-support/Jenkinsfile
+++ b/dev-support/Jenkinsfile
@@ -34,6 +34,12 @@ pipeline {
     // where we check out to across stages
     BASEDIR = "${env.WORKSPACE}/component"
     YETUS_RELEASE = '0.7.0'
+    // where we'll write everything from different steps. Need a copy here so the final step
can check for success/failure.
+    OUTPUT_DIR_RELATIVE_GENERAL = 'output-general'
+    OUTPUT_DIR_RELATIVE_JDK7 = 'output-jdk7'
+    OUTPUT_DIR_RELATIVE_HADOOP2 = 'output-jdk8-hadoop2'
+    OUTPUT_DIR_RELATIVE_HADOOP3 = 'output-jdk8-hadoop3'
+
     PROJECT = 'hbase'
     PROJECT_PERSONALITY = 'https://raw.githubusercontent.com/apache/hbase/master/dev-support/hbase-personality.sh'
     // This section of the docs tells folks not to use the javadoc tag. older branches have
our old version of the check for said tag.
@@ -119,8 +125,8 @@ curl -L  -o personality.sh "${env.PROJECT_PERSONALITY}"
         // on branches that don't support jdk7, this will already be JAVA_HOME, so we'll
end up not
         // doing multijdk there.
         MULTIJDK = '/usr/lib/jvm/java-8-openjdk-amd64'
-        OUTPUT_DIR_RELATIVE = "output-general"
-        OUTPUT_DIR = "${env.WORKSPACE}/${env.OUTPUT_DIR_RELATIVE}"
+        OUTPUT_DIR_RELATIVE = "${env.OUTPUT_DIR_RELATIVE_GENERAL}"
+        OUTPUT_DIR = "${env.WORKSPACE}/${env.OUTPUT_DIR_RELATIVE_GENERAL}"
       }
       steps {
         unstash 'yetus'
@@ -130,7 +136,18 @@ curl -L  -o personality.sh "${env.PROJECT_PERSONALITY}"
           "${BASEDIR}/dev-support/gather_machine_environment.sh" "${OUTPUT_DIR_RELATIVE}/machine"
 '''
         // TODO should this be a download from master, similar to how the personality is?
-        sh "${env.BASEDIR}/dev-support/hbase_nightly_yetus.sh"
+        sh '''#!/usr/bin/env bash
+          declare commentfile
+          rm -rf "${OUTPUT_DIR}/success}" "${OUTPUT_DIR}/failure"
+          if "${BASEDIR}/dev-support/hbase_nightly_yetus.sh" ; then
+            commentfile="${OUTPUT_DIR}/success"
+            echo '(/) {color:green}+1 general checks{color}' >> "${commentfile}"
+          else
+            commentfile="${OUTPUT_DIR}/failure"
+            echo '(x) {color:red}-1 general checks{color}' >> "${commentfile}"
+          fi
+          echo "-- For more information [see general report|${BUILD_URL}/General_Nightly_Build_Report/]"
>> "${commentfile}"
+        '''
       }
       post {
         always {
@@ -155,8 +172,8 @@ curl -L  -o personality.sh "${env.PROJECT_PERSONALITY}"
       }
       environment {
         TESTS = 'mvninstall,compile,javac,unit,htmlout'
-        OUTPUT_DIR_RELATIVE = "output-jdk7"
-        OUTPUT_DIR = "${env.WORKSPACE}/${env.OUTPUT_DIR_RELATIVE}"
+        OUTPUT_DIR_RELATIVE = "${env.OUTPUT_DIR_RELATIVE_JDK7}"
+        OUTPUT_DIR = "${env.WORKSPACE}/${env.OUTPUT_DIR_RELATIVE_JDK7}"
         // On branches where we do jdk7 checks, jdk7 will be JAVA_HOME already.
       }
       steps {
@@ -166,13 +183,22 @@ curl -L  -o personality.sh "${env.PROJECT_PERSONALITY}"
           rm -rf "${OUTPUT_DIR}/machine" && mkdir "${OUTPUT_DIR}/machine"
           "${BASEDIR}/dev-support/gather_machine_environment.sh" "${OUTPUT_DIR_RELATIVE}/machine"
 '''
-        sh """#!/usr/bin/env bash
+        sh '''#!/usr/bin/env bash
           # for branch-1.1 we don't do jdk8 findbugs, so do it here
-          if [ "${env.BRANCH_NAME}" == "branch-1.1" ]; then
+          if [ "${BRANCH_NAME}" == "branch-1.1" ]; then
             TESTS+=",findbugs"
           fi
-          "${env.BASEDIR}/dev-support/hbase_nightly_yetus.sh"
-        """
+          declare commentfile
+          rm -rf "${OUTPUT_DIR}/success}" "${OUTPUT_DIR}/failure"
+          if "${BASEDIR}/dev-support/hbase_nightly_yetus.sh" ; then
+            commentfile="${OUTPUT_DIR}/success"
+            echo '(/) {color:green}+1 jdk7 checks{color}' >> "${commentfile}"
+          else
+            commentfile="${OUTPUT_DIR}/failure"
+            echo '(x) {color:red}-1 jdk7 checks{color}' >> "${commentfile}"
+          fi
+          echo "-- For more information [see jdk7 report|${BUILD_URL}/JDK7_Nightly_Build_Report/]"
>> "${commentfile}"
+        '''
       }
       post {
         always {
@@ -214,8 +240,8 @@ curl -L  -o personality.sh "${env.PROJECT_PERSONALITY}"
       }
       environment {
         TESTS = 'mvninstall,compile,javac,unit,htmlout'
-        OUTPUT_DIR_RELATIVE = "output-jdk8-hadoop2"
-        OUTPUT_DIR = "${env.WORKSPACE}/${env.OUTPUT_DIR_RELATIVE}"
+        OUTPUT_DIR_RELATIVE = "${env.OUTPUT_DIR_RELATIVE_HADOOP2}"
+        OUTPUT_DIR = "${env.WORKSPACE}/${env.OUTPUT_DIR_RELATIVE_HADOOP2}"
         // This isn't strictly needed on branches that only support jdk8, but doesn't hurt
         // and is needed on branches that do both jdk7 and jdk8
         SET_JAVA_HOME = '/usr/lib/jvm/java-8-openjdk-amd64'
@@ -227,7 +253,18 @@ curl -L  -o personality.sh "${env.PROJECT_PERSONALITY}"
           rm -rf "${OUTPUT_DIR}/machine" && mkdir "${OUTPUT_DIR}/machine"
           "${BASEDIR}/dev-support/gather_machine_environment.sh" "${OUTPUT_DIR_RELATIVE}/machine"
 '''
-        sh "${env.BASEDIR}/dev-support/hbase_nightly_yetus.sh"
+        sh '''#!/usr/bin/env bash
+          declare commentfile
+          rm -rf "${OUTPUT_DIR}/success}" "${OUTPUT_DIR}/failure"
+          if "${BASEDIR}/dev-support/hbase_nightly_yetus.sh" ; then
+            commentfile="${OUTPUT_DIR}/success"
+            echo '(/) {color:green}+1 jdk8 hadoop2 checks{color}' >> "${commentfile}"
+          else
+            commentfile="${OUTPUT_DIR}/failure"
+            echo '(x) {color:red}-1 jdk8 hadoop2 checks{color}' >> "${commentfile}"
+          fi
+          echo "-- For more information [see jdk8 (hadoop2) report|${BUILD_URL}/JDK8_Nightly_Build_Report_(Hadoop2)/]"
>> "${commentfile}"
+        '''
       }
       post {
         always {
@@ -272,8 +309,8 @@ curl -L  -o personality.sh "${env.PROJECT_PERSONALITY}"
         // Findbugs is part of this last yetus stage to prevent findbugs precluding hadoop3
         // tests.
         TESTS = 'mvninstall,compile,javac,unit,findbugs,htmlout'
-        OUTPUT_DIR_RELATIVE = "output-jdk8-hadoop3"
-        OUTPUT_DIR = "${env.WORKSPACE}/${env.OUTPUT_DIR_RELATIVE}"
+        OUTPUT_DIR_RELATIVE = "${env.OUTPUT_DIR_RELATIVE_HADOOP3}"
+        OUTPUT_DIR = "${env.WORKSPACE}/${env.OUTPUT_DIR_RELATIVE_HADOOP3}"
         // This isn't strictly needed on branches that only support jdk8, but doesn't hurt
         // and is needed on branches that do both jdk7 and jdk8
         SET_JAVA_HOME = '/usr/lib/jvm/java-8-openjdk-amd64'
@@ -287,7 +324,18 @@ curl -L  -o personality.sh "${env.PROJECT_PERSONALITY}"
           rm -rf "${OUTPUT_DIR}/machine" && mkdir "${OUTPUT_DIR}/machine"
           "${BASEDIR}/dev-support/gather_machine_environment.sh" "${OUTPUT_DIR_RELATIVE}/machine"
 '''
-        sh "${env.BASEDIR}/dev-support/hbase_nightly_yetus.sh"
+        sh '''#!/usr/bin/env bash
+          declare commentfile
+          rm -rf "${OUTPUT_DIR}/success}" "${OUTPUT_DIR}/failure"
+          if "${BASEDIR}/dev-support/hbase_nightly_yetus.sh" ; then
+            commentfile="${OUTPUT_DIR}/success"
+            echo '(/) {color:green}+1 jdk8 hadoop3 checks{color}' >> "${commentfile}"
+          else
+            commentfile="${OUTPUT_DIR}/failure"
+            echo '(x) {color:red}-1 jdk8 hadoop3 checks{color}' >> "${commentfile}"
+          fi
+          echo "-- For more information [see jdk8 (hadoop3) report|${BUILD_URL}/JDK8_Nightly_Build_Report_(Hadoop3)/]"
>> "${commentfile}"
+        '''
       }
       post {
         always {
@@ -337,6 +385,7 @@ curl -L  -o personality.sh "${env.PROJECT_PERSONALITY}"
           rm -rf "unpacked_src_tarball" && mkdir "unpacked_src_tarball"
           rm -rf ".m2-for-repo" && mkdir ".m2-for-repo"
           rm -rf ".m2-for-src" && mkdir ".m2-for-src"
+          rm -rf "src_tarball_success" "src_tarball_failure"
 '''
         sh '''#!/usr/bin/env bash
           rm -rf "output-srctarball/machine" && mkdir "output-srctarball/machine"
@@ -356,7 +405,93 @@ curl -L  -o personality.sh "${env.PROJECT_PERSONALITY}"
         always {
           archive 'output-srctarball/*'
         }
+        // This approach only works because the source release artifact is the last stage
that does work.
+        success {
+          writeFile file: "${env.WORKSPACE}/src_tarball_success", text: '(/) {color:green}+1
source release artifact{color}\n-- See build output for details.'
+        }
+        failure {
+          writeFile file: "${env.WORKSPACE}/src_tarball_failure", text: '(x) {color:red}-1
source release artifact{color}\n-- See build output for details.'
+        }
+      }
+    }
+    stage ('Fail if previous stages failed') {
+      steps {
+        script {
+          def failures = ['src_tarball_failure', "${env.OUTPUT_DIR_RELATIVE_GENERAL}/failure",
+                          "${env.OUTPUT_DIR_RELATIVE_JDK7}/failure", "${OUTPUT_DIR_RELATIVE_HADOOP2}/failure",
+                          "${env.OUTPUT_DIR_RELATIVE_HADOOP3}/failure"]
+          for ( failure_file in failures ) {
+            if (fileExists(file: failure_file)) {
+              error 'Failing job due to failure(s) in prior steps.'
+            }
+          }
+        }
+      }
+    }
+  }
+  post {
+    always {
+      script {
+         try {
+           sh "printenv"
+           def results = ["${env.OUTPUT_DIR_RELATIVE_GENERAL}/failure", "${env.OUTPUT_DIR_RELATIVE_GENERAL}/success",
+                          "${env.OUTPUT_DIR_RELATIVE_JDK7}/failure", "${env.OUTPUT_DIR_RELATIVE_JDK7}/success",
+                          "${env.OUTPUT_DIR_RELATIVE_HADOOP2}/failure", "${env.OUTPUT_DIR_RELATIVE_HADOOP2}/success",
+                          "${env.OUTPUT_DIR_RELATIVE_HADOOP3}/failure", "${env.OUTPUT_DIR_RELATIVE_HADOOP3}/success",
+                          'src_tarball_failure', 'src_tarball_success']
+           echo env.BRANCH_NAME
+           echo env.BUILD_URL
+           echo currentBuild.result
+           echo currentBuild.durationString
+           def comment = "Results for branch ${env.BRANCH_NAME}, done in ${currentBuild.durationString}\n"
+           comment += "\t[build ${currentBuild.displayName} on builds.a.o|${env.BUILD_URL}]:
${currentBuild.result}\n----\ndetails (if available):\n\n"
+           if (currentBuild.result == "SUCCESS") {
+              comment += "(/) *{color:green}+1 overall{color}*\n\n"
+           } else {
+              comment += "(x) *{color:red}-1 overall{color}*\n"
+              // Ideally get the committer our of the change and @ mention them in the per-jira
comment
+              comment += "    Committer, please check your recent inclusion of a patch for
this issue.\n\n"
+           }
+           echo ""
+           echo "[DEBUG] trying to aggregate step-wise results"
+           comment += results.collect { fileExists(file: it) ? readFile(file: it) : "" }.join("\n\n")
+           echo "[INFO] Comment:"
+           echo comment
+           echo ""
+           echo "[INFO] There are ${currentBuild.changeSets.size()} change sets."
+           getJirasToComment(currentBuild).each { currentIssue ->
+             jiraComment issueKey: currentIssue, body: comment
+           }
+        } catch (Exception exception) {
+          echo "Got exception: ${exception}"
+          echo "    ${exception.getStackTrace()}"
+        }
+      }
+    }
+  }
+}
+import org.jenkinsci.plugins.workflow.support.steps.build.RunWrapper
+@NonCPS
+List<String> getJirasToComment(RunWrapper thisBuild) {
+  def seenJiras = []
+  thisBuild.changeSets.each { cs ->
+    cs.getItems().each { change ->
+      CharSequence msg = change.msg
+      echo "change: ${change}"
+      echo "     ${msg}"
+      echo "     ${change.commitId}"
+      echo "     ${change.author}"
+      echo ""
+      msg.eachMatch("HBASE-[0-9]+") { currentIssue ->
+        echo "[DEBUG] found jira key: ${currentIssue}"
+        if (currentIssue in seenJiras) {
+          echo "[DEBUG] already commented on ${currentIssue}."
+        } else {
+          echo "[INFO] commenting on ${currentIssue}."
+          seenJiras << currentIssue
+        }
       }
     }
   }
+  return seenJiras
 }


Mime
View raw message