Repository: oozie
Updated Branches:
  refs/heads/master 5fe2d4dfc -> eb79701e4


OOZIE-3162 Precommit build fails to add comment to JIRA (asasvari)


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

Branch: refs/heads/master
Commit: eb79701e465d47caf866ead02aaba58b07504979
Parents: 5fe2d4d
Author: Attila Sasvari <asasv...@cloudera.com>
Authored: Wed Jan 17 11:20:08 2018 +0100
Committer: Attila Sasvari <asasv...@cloudera.com>
Committed: Wed Jan 17 11:20:08 2018 +0100

----------------------------------------------------------------------
 bin/test-patch  | 28 ++++++++++++----------------
 release-log.txt |  1 +
 2 files changed, 13 insertions(+), 16 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/oozie/blob/eb79701e/bin/test-patch
----------------------------------------------------------------------
diff --git a/bin/test-patch b/bin/test-patch
index 33a6d11..d729120 100755
--- a/bin/test-patch
+++ b/bin/test-patch
@@ -108,22 +108,17 @@ prepareTestPatchDirs() {
 updateJira() {
   if [[ "${JIRAUPDATE}" != "" && "${JIRAISSUE}" != "" ]] ; then
     if [[ "$JIRAPASSWORD" != "" ]] ; then
-      JIRACLI=${TOOLSDIR}/jira-cli/jira.sh
-      if [ ! -e "${JIRACLI}" ] ; then
-        curl -L 
https://bobswift.atlassian.net/wiki/download/attachments/16285777/jira-cli-2.6.0-distribution.zip
 > ${TEMPDIR}/jira-cli.zip
-        if [ $? != 0 ] ; then
-         echo
-         echo "Could not download jira-cli tool, thus no JIRA updating"
-         echo
-         exit 1
-        fi
-        mkdir ${TEMPDIR}/jira-cli-tmp
-        (cd ${TEMPDIR}/jira-cli-tmp;jar xf ${TEMPDIR}/jira-cli.zip; mv 
jira-cli-2.6.0 ${TOOLSDIR}/jira-cli)
-        chmod u+x ${JIRACLI}
-      fi
       echo "Adding comment to JIRA"
-      comment=`cat ${SUMMARYFILE}`
-      $JIRACLI -s $JIRAURL -a addcomment -u $JIRAUSER -p "$JIRAPASSWORD" 
--comment "$comment" --issue $JIRAISSUE
+
+      # Replace newlines with \n so that summary can be sent via JSON to JIRA
+      comment=$(awk '{printf "%s\\n", $0}' ${SUMMARYFILE})
+
+      curl -u "${JIRAUSER}:${JIRAPASSWORD}"\
+           -H "Content-type: application/json"\
+           -H "Accept: application/json"\
+           -X POST\
+           --data '{"body": "'${comment}'"}'\
+           ${JIRAURL}/rest/api/2/issue/${JIRAISSUE}/comment || echo "Failed to 
add comment to JIRA"
       echo
     else
       echo "Skipping JIRA update"
@@ -366,6 +361,8 @@ parseArgs "$@"
 
 prepareTestPatchDirs
 
+echo -n "PreCommit-OOZIE-Build started" > ${SUMMARYFILE}
+updateJira
 echo "" > ${SUMMARYFILE}
 echo "" > ${SUMMARYFILE_FULL}
 
@@ -384,7 +381,6 @@ else
   summary_both "Testing patch ${PATCHFILE}"
   summary_both ""
 fi
-
 prepareSCM
 
 summary_both ""

http://git-wip-us.apache.org/repos/asf/oozie/blob/eb79701e/release-log.txt
----------------------------------------------------------------------
diff --git a/release-log.txt b/release-log.txt
index 5feb3ce..40946fa 100644
--- a/release-log.txt
+++ b/release-log.txt
@@ -1,5 +1,6 @@
 -- Oozie 5.0.0 release (trunk - unreleased)
 
+OOZIE-3162 Precommit build fails to add comment to JIRA (asasvari)
 OOZIE-1401 amend PurgeCommand should purge the workflow jobs w/o end_time 
(andras.piros, asasvari)
 OOZIE-3085 Improve logging in ActionExecutors: add log entry for start(), 
end() and kill() (kmarton via andras.piros)
 OOZIE-3083 Make improved version Info backward compatible (gezapeti via 
asasvari)

Reply via email to