Skip to content
This repository has been archived by the owner on Jun 21, 2024. It is now read-only.

change(jira-auth): change JIRA auth method to use PAT #56

Merged
merged 1 commit into from
Oct 25, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 6 additions & 2 deletions sync_issues_to_jira/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -183,11 +183,15 @@ The environment variables should be set in the GitHub Workflow:
- `JIRA_ISSUE_TYPE` (optional) the JIRA issue type for new issues. If unset, "Task" is used.
- `JIRA_COMPONENT` (optional) the name of a JIRA component to add to every issue which is synced from GitHub. The component must already exist in the JIRA project.

The following secrets should be set in the workflow:
The following secrets are needed for the workflow:

- `JIRA_URL` is the main JIRA URL (doesn't have to be secret).
- `JIRA_USER` is the JIRA username to log in with (JIRA basic auth)
- `JIRA_PASS` is the JIRA password to log in with (JIRA basic auth)
- `JIRA_PASS` is JIRA token (JIRA token auth) or JIRA password (JIRA basic auth) to log in with

If `JIRA_PASS` is a token, it must be entered in the secret with the prefix `token:` (e.g.: `token:Xyz123**************ABC`). The `token:` prefix is used to distinguish between a password and a token type of `JIRA_PASS`. This prefix will be stripped by the script before the API call.

***IMPORTANT:** These secrets are inherited from the GitHub organizational secrets (as they are common to all Espressif GitHub projects) and should not be set at the repository level. (If set at the repository level, repo secrets take precedence over org secrets.)*

# Tests

Expand Down
11 changes: 10 additions & 1 deletion sync_issues_to_jira/sync_to_jira.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,16 @@ def main():

# Connect to Jira server
print('Connecting to Jira Server...')
jira = _JIRA(os.environ['JIRA_URL'], basic_auth=(os.environ['JIRA_USER'], os.environ['JIRA_PASS']))

# Check if the JIRA_PASS is token or password
token_or_pass = os.environ['JIRA_PASS']
if token_or_pass.startswith('token:'):
print("Authenticating with JIRA_TOKEN ...")
token = token_or_pass[6:] # Strip the 'token:' prefix
jira = _JIRA(os.environ['JIRA_URL'], token_auth=token)
else:
print("Authenticating with JIRA_USER and JIRA_PASS ...")
jira = _JIRA(os.environ['JIRA_URL'], basic_auth=(os.environ['JIRA_USER'], token_or_pass))

# Check if it's a cron job
if os.environ.get('INPUT_CRON_JOB'):
Expand Down