Repository: yetus
Updated Branches:
  refs/heads/master e37f76335 -> 4475b0fd4


YETUS-46. releasedocmaker should support JIRA authentication

Signed-off-by: Jack Bearden <[email protected]>


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

Branch: refs/heads/master
Commit: 65394866210478b2b9f70253b7dcd4f2277857ae
Parents: e37f763
Author: Allen Wittenauer <[email protected]>
Authored: Sat Jul 21 14:41:01 2018 -0700
Committer: Allen Wittenauer <[email protected]>
Committed: Wed Aug 1 04:39:10 2018 -0700

----------------------------------------------------------------------
 .../in-progress/releasedocmaker.md              | 12 +++++++++++-
 release-doc-maker/utils.py                      | 20 +++++++++++++++-----
 2 files changed, 26 insertions(+), 6 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/yetus/blob/65394866/asf-site-src/source/documentation/in-progress/releasedocmaker.md
----------------------------------------------------------------------
diff --git a/asf-site-src/source/documentation/in-progress/releasedocmaker.md 
b/asf-site-src/source/documentation/in-progress/releasedocmaker.md
index 27a5d0a..6f86848 100644
--- a/asf-site-src/source/documentation/in-progress/releasedocmaker.md
+++ b/asf-site-src/source/documentation/in-progress/releasedocmaker.md
@@ -64,7 +64,6 @@ This will query Apache JIRA, generating two files in a 
directory named after the
 
 This is similar to the JIRA "Release Notes" button but is in tabular format 
and includes the priority, component, reporter, and contributor fields.  It 
also highlights Incompatible Changes so that readers know what to look out for 
when upgrading. The top of the file also includes the date that the version was 
marked as released in JIRA.
 
-
 * RELEASENOTES.md
 
 If your JIRA project supports the release note field, this will contain any 
JIRA mentioned in the CHANGELOG that is either an incompatible change or has a 
release note associated with it.  If your JIRA project does not support the 
release notes field, this will be the description field.
@@ -82,6 +81,17 @@ By default, release notes are expected to be in plain text.  
However, you can wr
 remaining text
 ```
 
+# Authentication
+
+releasedocmaker supports very simple Basic authentication.  This is 
accomplished by adding two environment variables to your shell environment:
+
+```bash
+RDM_JIRA_USERNAME='jirausername'
+RDM_JIRA_PASSWORD='jirapassword'
+```
+
+These values will be added to all requests destined for the JIRA server.
+
 # Changing the Header
 
 By default, it will use a header that matches the project name.  But that is 
kind of ugly and the case may be wrong.  Luckily, the title can be changed:

http://git-wip-us.apache.org/repos/asf/yetus/blob/65394866/release-doc-maker/utils.py
----------------------------------------------------------------------
diff --git a/release-doc-maker/utils.py b/release-doc-maker/utils.py
index 5bedf5a..1e025da 100644
--- a/release-doc-maker/utils.py
+++ b/release-doc-maker/utils.py
@@ -1,4 +1,4 @@
-#!/usr/bin/env python
+#!/usr/bin/env python2
 #
 # Licensed to the Apache Software Foundation (ASF) under one
 # or more contributor license agreements.  See the NOTICE file
@@ -16,6 +16,8 @@
 # See the License for the specific language governing permissions and
 # limitations under the License.
 
+import base64
+import os
 import re
 import urllib2
 import sys
@@ -26,7 +28,6 @@ sys.dont_write_bytecode = True
 NAME_PATTERN = re.compile(r' \([0-9]+\)')
 BASE_URL = "https://issues.apache.org/jira";
 
-
 def clean(input_string):
     return sanitize_markdown(re.sub(NAME_PATTERN, "", input_string))
 
@@ -35,8 +36,17 @@ def get_jira(jira_url):
     """ Provide standard method for fetching content from apache jira and
         handling of potential errors. Returns urllib2 response or
         raises one of several exceptions."""
+
+    username = os.environ.get('RDM_JIRA_USERNAME')
+    password = os.environ.get('RDM_JIRA_PASSWORD')
+
+    req = urllib2.Request(jira_url)
+    if username and password:
+        basicauth = base64.encodestring("%s:%s" % (username, 
password)).replace('\n', '')
+        req.add_header('Authorization', 'Basic %s' % basicauth)
+
     try:
-        response = urllib2.urlopen(jira_url)
+        response = urllib2.urlopen(req)
     except urllib2.HTTPError as http_err:
         code = http_err.code
         print "JIRA returns HTTP error %d: %s. Aborting." % \
@@ -44,8 +54,8 @@ def get_jira(jira_url):
         error_response = http_err.read()
         try:
             error_response = json.loads(error_response)
-            print "- Please ensure that specified projects, fixVersions etc."\
-                  " are correct."
+            print "- Please ensure that specified authentication, projects,"\
+                  " fixVersions etc. are correct."
             for message in error_response['errorMessages']:
                 print "-", message
         except ValueError:

Reply via email to