knox-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From kmin...@apache.org
Subject knox git commit: Add script used by PreCommit-KNOX-Scan jenkins job.
Date Thu, 21 Jan 2016 20:36:20 GMT
Repository: knox
Updated Branches:
  refs/heads/master fd0d5197b -> 30a5f7ece


Add script used by PreCommit-KNOX-Scan jenkins job.


Project: http://git-wip-us.apache.org/repos/asf/knox/repo
Commit: http://git-wip-us.apache.org/repos/asf/knox/commit/30a5f7ec
Tree: http://git-wip-us.apache.org/repos/asf/knox/tree/30a5f7ec
Diff: http://git-wip-us.apache.org/repos/asf/knox/diff/30a5f7ec

Branch: refs/heads/master
Commit: 30a5f7eceba22bdf8723f49e532b4671a2cdf1b3
Parents: fd0d519
Author: Kevin Minder <kevin.minder@hortonworks.com>
Authored: Thu Jan 21 15:36:08 2016 -0500
Committer: Kevin Minder <kevin.minder@hortonworks.com>
Committed: Thu Jan 21 15:36:16 2016 -0500

----------------------------------------------------------------------
 ...test-patch-find-new-patch-available-jiras.sh | 125 +++++++++++++++++++
 1 file changed, 125 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/knox/blob/30a5f7ec/dev-support/test-patch-find-new-patch-available-jiras.sh
----------------------------------------------------------------------
diff --git a/dev-support/test-patch-find-new-patch-available-jiras.sh b/dev-support/test-patch-find-new-patch-available-jiras.sh
new file mode 100755
index 0000000..3a3b639
--- /dev/null
+++ b/dev-support/test-patch-find-new-patch-available-jiras.sh
@@ -0,0 +1,125 @@
+#!/bin/bash
+#
+#   Licensed under the Apache License, Version 2.0 (the "License");
+#   you may not use this file except in compliance with the License.
+#   You may obtain a copy of the License at
+#
+#       http://www.apache.org/licenses/LICENSE-2.0
+#
+#   Unless required by applicable law or agreed to in writing, software
+#   distributed under the License is distributed on an "AS IS" BASIS,
+#   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+#   See the License for the specific language governing permissions and
+#   limitations under the License.
+
+if [ "${TESTPATCHDEBUG}" == "true" ] ; then
+  set -x
+fi
+
+BASEDIR=$(pwd)
+TEMPDIR=${BASEDIR}/tmp
+
+JIRAAVAILPATCHQUERY="https://issues.apache.org/jira/sr/jira.issueviews:searchrequest-xml/temp/SearchRequest.xml?jqlQuery=project+in+%28KNOX%29+AND+status+%3D+%22Patch+Available%22+ORDER+BY+updated+DESC&tempMax=1000"
+TESTPATCHJOBURL="https://builds.apache.org/job/PreCommit-Knox-Build"
+TOKEN=""
+SUBMIT="false"
+DELETEHISTORYFILE="false"
+
+RUNTESTSFILE=${BASEDIR}/TESTED_PATCHES.txt
+
+printUsage() {
+  echo "Usage: $0 <OPTIONS>"
+  echo "          --submit --token=<KNOX PRECOMMIT JOB TOKEN>"
+  echo "          [--delete-history-file]"
+  echo "          [--script-debug]"
+  echo
+}
+###############################################################################
+parseArgs() {
+  for i in $*
+  do
+    case $i in
+    --submit)
+      SUBMIT="true"
+      ;;
+    --token=*)
+      TOKEN=${i#*=}
+      ;;
+    --script-debug)
+      DEBUG="-x"
+      ;;
+    --delete-history-file)
+      DELETEHISTORYFILE="true"
+      ;;
+    *)
+      echo "Invalid option"
+      echo
+      printUsage
+      exit 1
+      ;;
+    esac
+  done
+  if [[ "$SUBMIT" == "true" && "${TOKEN}" == "" ]] ; then
+    echo "Token has not been specified"
+    echo
+    printUsage
+    exit 1
+  fi
+}
+###############################################################################
+findAndSubmitAvailablePatches() {
+
+## Grab all the key (issue numbers) and largest attachment id for each item in the XML
+curl --fail --location --retry 3 "${JIRAAVAILPATCHQUERY}" > ${TEMPDIR}/patch-availables.xml
+if [ "$?" != "0" ] ; then
+    echo "Could not retrieve available patches from JIRA"
+    exit 1
+fi
+xpath -q -e "//item/key/text() | //item/attachments/attachment[not(../attachment/@id >
@id)]/@id" ${TEMPDIR}/patch-availables.xml > ${TEMPDIR}/patch-attachments.element
+
+### Replace newlines with nothing, then replace id=" with =, then replace " with newline
+### to yield lines with pairs (issueNumber,largestAttachmentId). Example: KNOX-123,456984
+cat ${TEMPDIR}/patch-attachments.element | awk '{ if ( $1 ~ /^KNOX\-/) {JIRA=$1 }; if ($1
~ /id=/) { print JIRA","$1} }' | sed 's/id\="//' | sed 's/"//' > ${TEMPDIR}/patch-availables.pair
+
+### Iterate through issue list and find the (issueNumber,largestAttachmentId) pairs that
have
+### not been tested (ie don't already exist in the patch_tested.txt file
+touch ${RUNTESTSFILE}
+cat ${TEMPDIR}/patch-availables.pair | while read PAIR ; do
+  set +e
+  COUNT=`grep -c "$PAIR" ${RUNTESTSFILE}`
+  set -e
+  if [ "$COUNT" -lt "1" ] ; then
+    ### Parse $PAIR into project, issue number, and attachment id
+    ISSUE=`echo $PAIR | sed -e "s/,.*$//"`
+    echo "Found new patch for issue $ISSUE"
+    if [ "$SUBMIT" == "true" ]; then
+      ### Kick off job
+      echo "Submitting job for issue $ISSUE"
+      curl --fail --location --retry 3 "${TESTPATCHJOBURL}/buildWithParameters?token=${TOKEN}&JIRA_NUMBER=${ISSUE}"
> /dev/null
+      if [ "$?" != "0" ] ; then
+        echo "Could not submit precommit job for $ISSUE"
+        exit 1
+      fi
+    fi
+    ### Mark this pair as tested by appending to file
+    echo "$PAIR" >> ${RUNTESTSFILE}
+  fi
+done
+}
+###############################################################################
+
+mkdir ${TEMPDIR} 2>&1 $STDOUT
+
+parseArgs "$@"
+
+if [ -n "${DEBUG}" ] ; then
+  set -x
+fi
+
+if [ "${DELETEHISTORYFILE}" == "true" ] ; then
+  rm ${RUNTESTSFILE}
+fi
+
+findAndSubmitAvailablePatches
+
+exit 0


Mime
View raw message