diff --git a/.github/scripts/jira-get-release-notes/README.md b/.github/scripts/jira-get-release-notes/README.md index 088ca36bb1..e99b137bfe 100644 --- a/.github/scripts/jira-get-release-notes/README.md +++ b/.github/scripts/jira-get-release-notes/README.md @@ -40,7 +40,7 @@ Single line of release notes text ```json ... -"customfield_10335": { +"customfield_9999": { "type": "doc", "version": 1, "content": [ @@ -62,7 +62,7 @@ Single line of release notes text ```json ... -"customfield_10335": { +"customfield_9999": { "type": "doc", "version": 1, "content": [ diff --git a/.github/scripts/jira-get-release-notes/jira_release_notes.py b/.github/scripts/jira-get-release-notes/jira_release_notes.py index 999b831798..be8c45184f 100755 --- a/.github/scripts/jira-get-release-notes/jira_release_notes.py +++ b/.github/scripts/jira-get-release-notes/jira_release_notes.py @@ -5,6 +5,8 @@ import base64 import json import requests +SCRIPT_NAME = "jira_release_notes.py" + def extract_text_from_content(content): if isinstance(content, list): texts = [extract_text_from_content(item) for item in content] @@ -23,19 +25,42 @@ def extract_text_from_content(content): return '' -def parse_release_notes(response_json): - try: - fields = response_json.get('fields', {}) - release_notes_field = fields.get('customfield_10335', {}) +def log_customfields_with_content(fields): + """Log all customfield_* fields that have a 'content' key to help troubleshoot structure changes.""" + print(f"[{SCRIPT_NAME}] Available customfield_* fields with 'content':", file=sys.stderr) + found = False + for key, value in fields.items(): + if key.startswith('customfield_') and isinstance(value, dict) and 'content' in value: + found = True + print(f"[{SCRIPT_NAME}] {key}: {json.dumps(value, indent=2)}", file=sys.stderr) + if not found: + print(f"[{SCRIPT_NAME}] None found", file=sys.stderr) - if not release_notes_field or not release_notes_field.get('content'): +def parse_release_notes(response_json): + release_notes_field_name = 'customfield_10309' + try: + fields = response_json.get('fields') + if not fields: + print(f"[{SCRIPT_NAME}] 'fields' is empty or missing in response", file=sys.stderr) return '' - release_notes = extract_text_from_content(release_notes_field.get('content', [])) + release_notes_field = fields.get(release_notes_field_name) + if not release_notes_field: + print(f"[{SCRIPT_NAME}] Release notes field is empty or missing. Field name: {release_notes_field_name}", file=sys.stderr) + log_customfields_with_content(fields) + return '' + + content = release_notes_field.get('content', []) + if not content: + print(f"[{SCRIPT_NAME}] Release notes field was found but 'content' is empty or missing in {release_notes_field_name}", file=sys.stderr) + log_customfields_with_content(fields) + return '' + + release_notes = extract_text_from_content(content) return release_notes except Exception as e: - print(f"Error parsing release notes: {str(e)}", file=sys.stderr) + print(f"[{SCRIPT_NAME}] Error parsing release notes: {str(e)}", file=sys.stderr) return '' def main(): @@ -60,7 +85,7 @@ def main(): ) if response.status_code != 200: - print(f"Error fetching Jira issue: {response.status_code}", file=sys.stderr) + print(f"[{SCRIPT_NAME}] Error fetching Jira issue ({jira_issue_id}). Status code: {response.status_code}. Msg: {response.text}", file=sys.stderr) sys.exit(1) release_notes = parse_release_notes(response.json()) diff --git a/.github/workflows/github-release.yml b/.github/workflows/github-release.yml index 7a0230eba2..1b61be0fbe 100644 --- a/.github/workflows/github-release.yml +++ b/.github/workflows/github-release.yml @@ -183,11 +183,15 @@ jobs: _JIRA_API_EMAIL: ${{ steps.get-kv-secrets.outputs.JIRA-API-EMAIL }} _JIRA_API_TOKEN: ${{ steps.get-kv-secrets.outputs.JIRA-API-TOKEN }} run: | - echo "Getting product release notes" - product_release_notes=$(python3 .github/scripts/jira-get-release-notes/jira_release_notes.py "$_RELEASE_TICKET_ID" "$_JIRA_API_EMAIL" "$_JIRA_API_TOKEN") + echo "Getting product release notes..." + # capture output and exit code so this step continues even if we can't retrieve release notes. + script_exit_code=0 + product_release_notes=$(python .github/scripts/jira-get-release-notes/jira_release_notes.py "$_RELEASE_TICKET_ID" "$_JIRA_API_EMAIL" "$_JIRA_API_TOKEN") || script_exit_code=$? + echo "--------------------------------" - if [[ -z "$product_release_notes" || $product_release_notes == "Error checking"* ]]; then - echo "::warning::Failed to fetch release notes from Jira. Output: $product_release_notes" + if [[ $script_exit_code -ne 0 || -z "$product_release_notes" ]]; then + echo "Script Output: $product_release_notes" + echo "::warning::Failed to fetch release notes from Jira. Check script logs for more details." product_release_notes="" else echo "✅ Product release notes:" @@ -285,5 +289,5 @@ jobs: echo " * :ocean: Previous tag set in the description \"Full Changelog\" link: \`$_LAST_RELEASE_TAG\`" echo " * :white_check_mark: Description has automated release notes and they match the commits in the release branch" echo "> [!NOTE]" - echo "> Commits directly pushed to branches without a Pull Request won't appear in the automated release notes." + echo "> Commits directly pushed to branches without a Pull Request won't appear in the automated release notes." } >> "$GITHUB_STEP_SUMMARY"