This is an automated email from the ASF dual-hosted git repository.

yao pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/spark.git


The following commit(s) were added to refs/heads/master by this push:
     new c36d54a569e [SPARK-44802][INFRA] Token based ASF JIRA authentication
c36d54a569e is described below

commit c36d54a569e59e823aab83f47b97ae286fd7f4c4
Author: Kent Yao <y...@apache.org>
AuthorDate: Tue Aug 15 13:39:16 2023 +0800

    [SPARK-44802][INFRA] Token based ASF JIRA authentication
    
    ### What changes were proposed in this pull request?
    
    This PR add a env JIRA_ACCESS_TOKEN for merge script to enable token auth
    
    ### Why are the changes needed?
    
    Tokens are more secure and easily revoked or expired.
    
    ### Does this PR introduce _any_ user-facing change?
    
    no
    
    ### How was this patch tested?
    
    1. locally tested
    
    ```python
    >>> JIRA_ACCESS_TOKEN is not None
    True
    >>> asf_jira.issue("SPARK-44801")
    <JIRA Issue: key='SPARK-44801', id='13547185'>
    >>> if JIRA_ACCESS_TOKEN is not None:
    ...     asf_jira = jira.client.JIRA(jira_server, 
token_auth=JIRA_ACCESS_TOKEN)
    ... else:
    ...     asf_jira = jira.client.JIRA(
    ...         jira_server, basic_auth=(JIRA_USERNAME, JIRA_PASSWORD)
    ...     )
    ...
    >>> asf_jira.issue("SPARK-44801")
    <JIRA Issue: key='SPARK-44801', id='13547185'>
    ```
    
    2. merged https://github.com/apache/spark/pull/42470 with this
    
    Closes #42484 from yaooqinn/SPARK-44802.
    
    Authored-by: Kent Yao <y...@apache.org>
    Signed-off-by: Kent Yao <y...@apache.org>
---
 dev/merge_spark_pr.py | 14 +++++++++++---
 1 file changed, 11 insertions(+), 3 deletions(-)

diff --git a/dev/merge_spark_pr.py b/dev/merge_spark_pr.py
index c96415c7aeb..0fd42e237a4 100755
--- a/dev/merge_spark_pr.py
+++ b/dev/merge_spark_pr.py
@@ -52,6 +52,11 @@ PUSH_REMOTE_NAME = os.environ.get("PUSH_REMOTE_NAME", 
"apache")
 JIRA_USERNAME = os.environ.get("JIRA_USERNAME", "")
 # ASF JIRA password
 JIRA_PASSWORD = os.environ.get("JIRA_PASSWORD", "")
+# ASF JIRA access token
+# If it is configured, username and password are dismissed
+# Go to https://issues.apache.org/jira/secure/ViewProfile.jspa -> Personal 
Access Tokens for
+# your own token management.
+JIRA_ACCESS_TOKEN = os.environ.get("JIRA_ACCESS_TOKEN")
 # OAuth key used for issuing requests against the GitHub API. If this is not 
defined, then requests
 # will be unauthenticated. You should only need to configure this if you find 
yourself regularly
 # exceeding your IP's unauthenticated request rate limit. You can create an 
OAuth key at
@@ -238,9 +243,12 @@ def cherry_pick(pr_num, merge_hash, default_branch):
 
 
 def resolve_jira_issue(merge_branches, comment, default_jira_id=""):
-    asf_jira = jira.client.JIRA(
-        {"server": JIRA_API_BASE}, basic_auth=(JIRA_USERNAME, JIRA_PASSWORD)
-    )
+    jira_server = {"server": JIRA_API_BASE}
+
+    if JIRA_ACCESS_TOKEN is not None:
+        asf_jira = jira.client.JIRA(jira_server, token_auth=JIRA_ACCESS_TOKEN)
+    else:
+        asf_jira = jira.client.JIRA(jira_server, basic_auth=(JIRA_USERNAME, 
JIRA_PASSWORD))
 
     jira_id = input("Enter a JIRA id [%s]: " % default_jira_id)
     if jira_id == "":


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscr...@spark.apache.org
For additional commands, e-mail: commits-h...@spark.apache.org

Reply via email to