SENTRY-767: SENTRY jenkins support test the patch for branch ( Dapeng Sun via Sravya Tirukkovalur)
Project: http://git-wip-us.apache.org/repos/asf/incubator-sentry/repo Commit: http://git-wip-us.apache.org/repos/asf/incubator-sentry/commit/4e03bdb2 Tree: http://git-wip-us.apache.org/repos/asf/incubator-sentry/tree/4e03bdb2 Diff: http://git-wip-us.apache.org/repos/asf/incubator-sentry/diff/4e03bdb2 Branch: refs/heads/hive_plugin_v2 Commit: 4e03bdb24145eb56378c29aa6db23d7ac1d25d62 Parents: 198bef5 Author: Sravya Tirukkovalur <[email protected]> Authored: Thu Jun 18 10:34:54 2015 -0700 Committer: Sravya Tirukkovalur <[email protected]> Committed: Thu Jun 18 10:34:54 2015 -0700 ---------------------------------------------------------------------- dev-support/test-patch.py | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/incubator-sentry/blob/4e03bdb2/dev-support/test-patch.py ---------------------------------------------------------------------- diff --git a/dev-support/test-patch.py b/dev-support/test-patch.py index 7e701c3..d36e7fd 100644 --- a/dev-support/test-patch.py +++ b/dev-support/test-patch.py @@ -88,7 +88,7 @@ def jira_post_comment(result, defect, branch, username, password): # hack (from hadoop) but REST api doesn't list attachments? def jira_get_attachment(result, defect, username, password): html = jira_get_defect_html(result, defect, username, password) - pattern = "(/secure/attachment/[0-9]+/%s[0-9\.\-]*\.(patch|txt|patch\.txt))" % (re.escape(defect)) + pattern = "(/secure/attachment/\d+/%s[\w\.\-]*\.(patch|txt|patch\.txt))" % (re.escape(defect)) matches = [] for match in re.findall(pattern, html, re.IGNORECASE): matches += [ match[0] ] @@ -282,6 +282,16 @@ if defect: print "ERROR: No attachments found for %s" % (defect) sys.exit(1) result.attachment = attachment + # parse branch info + branchPattern = re.compile('/secure/attachment/\d+/%s(\.\d+)-(\w+)\.(patch|txt|patch.\txt)' % (re.escape(defect))) + try: + branchInfo = re.search(branchPattern,attachment) + if branchInfo: + branch = branchInfo.group(2) + print "INFO: Branch info is detected from attachment name: " + branch + except: + branch = "master" + print "INFO: Branch info is not detected from attachment name, use branch: " + branch patch_contents = jira_request(result, result.attachment, username, password, None, {}).read() patch_file = "%s/%s.patch" % (output_dir, defect) with open(patch_file, 'a') as fh:
