You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@yetus.apache.org by aw...@apache.org on 2018/08/01 11:40:43 UTC

[1/2] yetus git commit: YETUS-46. releasedocmaker should support JIRA authentication

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


YETUS-46. releasedocmaker should support JIRA authentication

Signed-off-by: Jack Bearden <ja...@jackbearden.com>


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 <aw...@apache.org>
Authored: Sat Jul 21 14:41:01 2018 -0700
Committer: Allen Wittenauer <aw...@apache.org>
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:


[2/2] yetus git commit: YETUS-647. ssh-based git repos do not work correctly under docker

Posted by aw...@apache.org.
YETUS-647. ssh-based git repos do not work correctly under docker

Signed-off-by: Jack Bearden <ja...@jackbearden.com>


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

Branch: refs/heads/master
Commit: 4475b0fd451f9287b8618f49cd59286d2e7da9e0
Parents: 6539486
Author: Allen Wittenauer <aw...@apache.org>
Authored: Sun Jul 29 19:09:12 2018 -0700
Committer: Allen Wittenauer <aw...@apache.org>
Committed: Wed Aug 1 04:40:17 2018 -0700

----------------------------------------------------------------------
 precommit/test-patch.sh | 91 ++++++++++++++++++++++++++++++++++----------
 1 file changed, 70 insertions(+), 21 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/yetus/blob/4475b0fd/precommit/test-patch.sh
----------------------------------------------------------------------
diff --git a/precommit/test-patch.sh b/precommit/test-patch.sh
index eb7bb45..93b20df 100755
--- a/precommit/test-patch.sh
+++ b/precommit/test-patch.sh
@@ -91,6 +91,8 @@ function setup_defaults
 
   # shellcheck disable=SC2034
   CHANGED_UNION_MODULES=""
+
+  GIT_OFFLINE=false
   PROC_LIMIT=1000
   REEXECED=false
   RESETREPO=false
@@ -1277,6 +1279,28 @@ function find_changed_modules
   fi
 }
 
+## @description  check if repo requires ssh creds to pull
+## @audience     private
+## @stability    stable
+## @replaceable  no
+## @return       0 = no
+## @return       1 = yes
+function git_requires_creds
+{
+  declare status
+  declare -a remotes
+
+  # shellcheck disable=SC2207
+  remotes=( $("${GIT}" remote -v show -n) )
+
+  for r in "${remotes[@]}"; do
+    if [[ ${r} =~ /@/ ]] || [[ ${r} =~ git:// ]]; then
+      return 1
+    fi
+  done
+  return 0
+}
+
 ## @description  git checkout the appropriate branch to test.  Additionally, this calls
 ## @description  'determine_branch' based upon the context provided
 ## @description  in ${PATCH_DIR} and in git after checkout.
@@ -1286,9 +1310,10 @@ function find_changed_modules
 ## @return       0 on success.  May exit on failure.
 function git_checkout
 {
-  local currentbranch
-  local exemptdir
-  local status
+  declare currentbranch
+  declare exemptdir
+  declare status
+  declare pullmayfail=false
 
   big_console_header "Confirming git environment"
 
@@ -1298,6 +1323,10 @@ function git_checkout
     cleanup_and_exit 1
   fi
 
+  if git_requires_creds; then
+    pullmayfail=true
+  fi
+
   if [[ ${RESETREPO} == "true" ]] ; then
 
     if [[ -d .git/rebase-apply ]]; then
@@ -1305,8 +1334,7 @@ function git_checkout
       ${GIT} rebase --abort
     fi
 
-    ${GIT} reset --hard
-    if [[ $? != 0 ]]; then
+    if ! ${GIT} reset --hard; then
       yetus_error "ERROR: git reset is failing"
       cleanup_and_exit 1
     fi
@@ -1316,6 +1344,8 @@ function git_checkout
     exemptdir=$(relative_dir "${PATCH_DIR}")
     if [[ $? == 1 ]]; then
       ${GIT} clean -xdf
+      status=$?
+
     else
       # we do, however, want it emptied of all _files_.
       # we need to leave _directories_ in case we are in
@@ -1323,14 +1353,15 @@ function git_checkout
       yetus_debug "Exempting ${exemptdir} from clean"
       rm "${PATCH_DIR}/*" 2>/dev/null
       ${GIT} clean -xdf -e "${exemptdir}"
+      status=$?
     fi
-    if [[ $? != 0 ]]; then
+
+    if [[ ${status} != 0 ]]; then
       yetus_error "ERROR: git clean is failing"
       cleanup_and_exit 1
     fi
 
-    ${GIT} checkout --force "${PATCH_BRANCH_DEFAULT}"
-    if [[ $? != 0 ]]; then
+    if ! ${GIT} checkout --force "${PATCH_BRANCH_DEFAULT}"; then
       yetus_error "ERROR: git checkout --force ${PATCH_BRANCH_DEFAULT} is failing"
       cleanup_and_exit 1
     fi
@@ -1339,17 +1370,22 @@ function git_checkout
 
     # we need to explicitly fetch in case the
     # git ref hasn't been brought in tree yet
-    if [[ ${OFFLINE} == false ]]; then
-
-      ${GIT} pull --rebase
-      if [[ $? != 0 ]]; then
-        yetus_error "ERROR: git pull is failing"
-        cleanup_and_exit 1
+    if [[ ${OFFLINE} == false ]] && [[ ${GIT_OFFLINE} == false ]]; then
+
+      if ! ${GIT} pull --rebase; then
+        if [[ ${pullmayfail} == true ]]; then
+          yetus_error "WARNING: Noted that pull failed, will treat git as offline from here on out"
+          GIT_OFFLINE=true
+        else
+          yetus_error "ERROR: git pull is failing"
+          cleanup_and_exit 1
+        fi
       fi
     fi
+
     # forcibly checkout this branch or git ref
-    ${GIT} checkout --force "${PATCH_BRANCH}"
-    if [[ $? != 0 ]]; then
+
+    if ! ${GIT} checkout --force "${PATCH_BRANCH}"; then
       yetus_error "ERROR: git checkout ${PATCH_BRANCH} is failing"
       cleanup_and_exit 1
     fi
@@ -1357,11 +1393,24 @@ function git_checkout
     # if we've selected a feature branch that has new changes
     # since our last build, we'll need to reset to the latest FETCH_HEAD.
     if [[ ${OFFLINE} == false ]]; then
-      ${GIT} fetch
-      ${GIT} reset --hard FETCH_HEAD
-      ${GIT} clean -df
-      if [[ $? != 0 ]]; then
-        yetus_error "ERROR: git pull is failing"
+
+      # previous clause where GIT_OFFLINE would get set is also
+      # protected by OFFLINE == false
+
+      if [[ "${GIT_OFFLINE}" == false ]]; then
+        if ! ${GIT} fetch; then
+          yetus_error "ERROR: git fetch is failing"
+          cleanup_and_exit 1
+        fi
+
+        if ! ${GIT} reset --hard FETCH_HEAD; then
+          yetus_error "ERROR: git reset is failing"
+          cleanup_and_exit 1
+        fi
+      fi
+
+      if ! ${GIT} clean -df; then
+        yetus_error "ERROR: git clean is failing"
         cleanup_and_exit 1
       fi
     fi