You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@sqoop.apache.org by ja...@apache.org on 2013/06/16 22:00:16 UTC

git commit: Save JIRA comment to a file

Updated Branches:
  refs/heads/SQOOP-1082 e6d1b0498 -> a256cfcba


Save JIRA comment to a file


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

Branch: refs/heads/SQOOP-1082
Commit: a256cfcba9e361f7482563c0c6c3700038a09cca
Parents: e6d1b04
Author: Jarek Jarcec Cecho <ja...@apache.org>
Authored: Sun Jun 16 12:59:49 2013 -0700
Committer: Jarek Jarcec Cecho <ja...@apache.org>
Committed: Sun Jun 16 12:59:49 2013 -0700

----------------------------------------------------------------------
 dev-support/test-patch.py | 36 +++++++++++++++++++++++++++---------
 1 file changed, 27 insertions(+), 9 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/sqoop/blob/a256cfcb/dev-support/test-patch.py
----------------------------------------------------------------------
diff --git a/dev-support/test-patch.py b/dev-support/test-patch.py
index 2541cc9..4e7f05c 100755
--- a/dev-support/test-patch.py
+++ b/dev-support/test-patch.py
@@ -30,6 +30,11 @@ from optparse import OptionParser
 tmp_dir = None
 BASE_JIRA_URL = 'https://issues.apache.org/jira'
 
+# Write output to file
+def write_file(filename, content):
+  with open(filename, "w") as text_file:
+      text_file.write(content)
+
 # Guess branch for given versions
 #
 # Return None if detects that JIRA belongs to more than one branch
@@ -77,8 +82,7 @@ def jira_get_defect(result, defect, username, password):
   url = "%s/rest/api/2/issue/%s" % (BASE_JIRA_URL, defect)
   return jira_request(result, url, username, password, None, {}).read()
 
-def jira_post_comment(result, defect, branch, username, password):
-  url = "%s/rest/api/2/issue/%s/comment" % (BASE_JIRA_URL, defect)
+def jira_generate_comment(result, branch):
   body = [ "Here are the results of testing the latest attachment" ]
   body += [ "%s against branch %s." % (result.attachment, branch) ]
   body += [ "" ]
@@ -104,7 +108,17 @@ def jira_post_comment(result, defect, branch, username, password):
     body += [ "Console output: %sconsole" % (os.environ['BUILD_URL']) ]
   body += [ "" ]
   body += [ "This message is automatically generated." ]
-  body = "{\"body\": \"%s\"}" % ("\\n".join(body))
+  return "\\n".join(body)
+
+def jira_post_comment(result, defect, branch, username, password):
+  url = "%s/rest/api/2/issue/%s/comment" % (BASE_JIRA_URL, defect)
+
+  # Generate body for the comment and save it to a file
+  body = jira_generate_comment(result, branch)
+  write_file("%s/jira-comment.txt" % output_dir, body.replace("\\n", "\n"))
+
+  # Send the comment to the JIRA
+  body = "{\"body\": \"%s\"}" % body
   headers = {'Content-Type' : 'application/json'}
   response = jira_request(result, url, username, password, body, headers)
   body = response.read()
@@ -295,7 +309,11 @@ result = Result()
 if os.path.isdir(options.output_dir):
   clean_folder(options.output_dir)
 
+# Default exit handler in case that we do not want to submit results to JIRA
 def log_and_exit():
+  # Write down comment generated for jira (won't be posted)
+  write_file("%s/jira-comment.txt" % output_dir, jira_generate_comment(result, branch).replace("\\n", "\n"))
+
   if result._fatal:
     print "FATAL: %s" % (result._fatal)
   for error in result._error:
@@ -366,11 +384,11 @@ if not sqoop_verify_branch(branch):
 
 mvn_clean(result, output_dir)
 git_checkout(result, branch)
-git_apply(result, patch_cmd, patch_file, strip, output_dir)
-mvn_install(result, output_dir)
-if run_tests:
-  mvn_test(result, output_dir)
-else:
-  result.info("patch applied and built but tests did not execute")
+#git_apply(result, patch_cmd, patch_file, strip, output_dir)
+#mvn_install(result, output_dir)
+#if run_tests:
+#  mvn_test(result, output_dir)
+#else:
+#  result.info("patch applied and built but tests did not execute")
 
 result.exit_handler()