Skip to content

[WIP] Allow clickable TF/jira links#328

Open
bajertom wants to merge 1 commit intoRedHatQE:mainfrom
bajertom:allow-clickable-links
Open

[WIP] Allow clickable TF/jira links#328
bajertom wants to merge 1 commit intoRedHatQE:mainfrom
bajertom:allow-clickable-links

Conversation

@bajertom
Copy link
Copy Markdown
Contributor

@bajertom bajertom commented Mar 10, 2026

For debugging/configuring purposes I often run newa manually from the command line. I don't wait for the complete results, I just want to quickly get to the log on Testing Farm or see the Jira issues. That means highlighting the TF UUID/jira issue number in the newa output stream with a mouse, alt+shift+D to open doer and then mouse clicking on the correct line to open the desired interface. (Note: that does not work for staging jira instance, because that is not even present in the doer UI list)

This change introduces two options in newa.conf file to allow printing clickable links to TF/Jira in the newa output stream and getting the results quickly without the overhead of mouse-selecting and sometimes missclicking in doer.

Summary by Sourcery

Add configurable options to include clickable Testing Farm and Jira URLs in CLI logs for easier navigation from terminal output.

New Features:

  • Introduce jira_show_url and tf_show_url settings to control whether Jira and Testing Farm URLs are printed in logs.

Enhancements:

  • Extend Jira-related logging to optionally include direct issue URLs when searching, creating, or reusing issues.
  • Update Testing Farm worker logging to optionally print the artifacts URL instead of just the request UUID.

@sourcery-ai
Copy link
Copy Markdown

sourcery-ai bot commented Mar 10, 2026

Reviewer's Guide

This PR adds optional configuration flags to include clickable Testing Farm and Jira URLs in newa CLI logs, wiring the settings through the config loader and updating logging in Jira helpers and Testing Farm worker output to show full URLs when enabled.

Class diagram for updated Settings configuration options

classDiagram
    class Settings {
        # jira_token : str
        # jira_email : str
        # jira_project : str
        # jira_show_url : bool
        # tf_token : str
        # tf_recheck_delay : str
        # tf_show_url : bool
        # rog_token : str
        # ai_api_url : str
        # ai_api_token : str
    }

    class ConfigParser {
    }

    class SettingsLoader {
        +load_settings(config_parser cp) Settings
        -_get(config_parser cp, str key, str env_var, str default_value) str
        -_str_to_bool(str value) bool
    }

    ConfigParser <.. SettingsLoader : uses
    SettingsLoader ..> Settings : creates
Loading

Flow diagram for TF worker logging with optional URL

flowchart TD
    A[tf_worker starts handling TF request] --> B[Read tf_request details]
    B --> C{ctx.settings.tf_show_url?}
    C -- true --> D[log TF request execute_job.execution.artifacts_url with envs and state]
    C -- false --> E[log TF request tf_request.uuid with envs and state]
    D --> F[Check tf_request.is_finished]
    E --> F[Check tf_request.is_finished]
Loading

Flow diagram for Jira helper logging with optional URLs

flowchart TD
    A[_find_or_create_issue called] --> B[Iterate search_result items]
    B --> C{ctx.settings.jira_show_url?}
    C -- true --> D[logger.debug Checking key with ctx.settings.jira_url/browse/key]
    C -- false --> E[logger.debug Checking key]

    D --> F[Determine opened_issues and closed_issues]
    E --> F[Determine opened_issues and closed_issues]

    F --> G{opened_issues empty?}
    G -- yes --> H{ctx.settings.jira_show_url?}
    H -- true --> I[logger.info Relevant closed_ids with ctx.settings.jira_url/browse/closed_ids found but already closed]
    H -- false --> J[logger.info Relevant closed_ids found but already closed]

    G -- no --> K{Creating new issue?}
    K -- yes --> L{ctx.settings.jira_show_url?}
    L -- true --> M[logger.info New issue id created with ctx.settings.jira_url/browse/id]
    L -- false --> N[logger.info New issue id created]

    K -- no --> O{Reusing existing issue}
    O --> P{ctx.settings.jira_show_url?}
    P -- true --> Q[logger.info Issue new_issue with ctx.settings.jira_url/browse/new_issue re-used]
    P -- false --> R[logger.info Issue new_issue re-used]
Loading

File-Level Changes

Change Details Files
Add configuration flags to control whether Jira and Testing Farm URLs are printed in CLI output.
  • Extend Settings model with jira_show_url and tf_show_url boolean fields defaulting to False.
  • Load jira_show_url and tf_show_url from config file and environment variables using the existing boolean-parsing helper.
  • Introduce new config keys jira/show_url and testingfarm/show_url, and corresponding env vars NEWA_JIRA_SHOW_URL and NEWA_TF_SHOW_URL.
newa/models/settings.py
Include Jira issue URLs in debug and info logs when jira_show_url setting is enabled.
  • Update debug logging in _find_or_create_issue to append the Jira browse URL for each checked issue when jira_show_url is True.
  • Enhance info log when only closed relevant issues are found to append a Jira browse URL containing the closed issue IDs when jira_show_url is True.
  • Enhance info log when a new issue is created to append its Jira browse URL when jira_show_url is True.
  • Enhance info log when an existing issue is reused to append its Jira browse URL when jira_show_url is True.
newa/cli/jira_helpers.py
Include Testing Farm artifacts URL in TF worker logs when tf_show_url setting is enabled.
  • Change TF worker log line to output execute_job.execution.artifacts_url instead of the bare UUID when tf_show_url is True, preserving the original UUID-based message when False.
newa/cli/workers.py

Tips and commands

Interacting with Sourcery

  • Trigger a new review: Comment @sourcery-ai review on the pull request.
  • Continue discussions: Reply directly to Sourcery's review comments.
  • Generate a GitHub issue from a review comment: Ask Sourcery to create an
    issue from a review comment by replying to it. You can also reply to a
    review comment with @sourcery-ai issue to create an issue from it.
  • Generate a pull request title: Write @sourcery-ai anywhere in the pull
    request title to generate a title at any time. You can also comment
    @sourcery-ai title on the pull request to (re-)generate the title at any time.
  • Generate a pull request summary: Write @sourcery-ai summary anywhere in
    the pull request body to generate a PR summary at any time exactly where you
    want it. You can also comment @sourcery-ai summary on the pull request to
    (re-)generate the summary at any time.
  • Generate reviewer's guide: Comment @sourcery-ai guide on the pull
    request to (re-)generate the reviewer's guide at any time.
  • Resolve all Sourcery comments: Comment @sourcery-ai resolve on the
    pull request to resolve all Sourcery comments. Useful if you've already
    addressed all the comments and don't want to see them anymore.
  • Dismiss all Sourcery reviews: Comment @sourcery-ai dismiss on the pull
    request to dismiss all existing Sourcery reviews. Especially useful if you
    want to start fresh with a new review - don't forget to comment
    @sourcery-ai review to trigger a new review!

Customizing Your Experience

Access your dashboard to:

  • Enable or disable review features such as the Sourcery-generated pull request
    summary, the reviewer's guide, and others.
  • Change the review language.
  • Add, remove or edit custom review instructions.
  • Adjust other review settings.

Getting Help

Copy link
Copy Markdown

@sourcery-ai sourcery-ai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hey - I've found 1 issue, and left some high level feedback:

  • In the Relevant issues {closed_ids} branch you build a single Jira URL using closed_ids which can contain multiple comma-separated IDs, resulting in an invalid link; consider logging individual issue URLs or omitting the URL when multiple IDs are present.
  • There is repeated if ctx.settings.jira_show_url / tf_show_url logging logic that only differs in message formatting; consider extracting small helper functions to format Jira and TF log messages to keep this behavior consistent and easier to maintain.
  • In the Issue {new_issue} re-used log with jira_show_url enabled, the message concatenation lacks a space before re-used (.../{new_issue})re-used), which makes the log a bit hard to read; adding a space or using a single f-string would fix this.
Prompt for AI Agents
Please address the comments from this code review:

## Overall Comments
- In the `Relevant issues {closed_ids}` branch you build a single Jira URL using `closed_ids` which can contain multiple comma-separated IDs, resulting in an invalid link; consider logging individual issue URLs or omitting the URL when multiple IDs are present.
- There is repeated `if ctx.settings.jira_show_url` / `tf_show_url` logging logic that only differs in message formatting; consider extracting small helper functions to format Jira and TF log messages to keep this behavior consistent and easier to maintain.
- In the `Issue {new_issue} re-used` log with `jira_show_url` enabled, the message concatenation lacks a space before `re-used` (`.../{new_issue})re-used`), which makes the log a bit hard to read; adding a space or using a single f-string would fix this.

## Individual Comments

### Comment 1
<location path="newa/cli/jira_helpers.py" line_range="306-314" />
<code_context>

         for jira_issue_key, jira_issue in search_result.items():
-            ctx.logger.debug(f"Checking {jira_issue_key}")
+            if ctx.settings.jira_show_url:
+                ctx.logger.debug(
+                    f"Checking {jira_issue_key} "
</code_context>
<issue_to_address>
**issue (bug_risk):** Building a single JIRA URL from a comma-separated list of IDs will produce an invalid link.

Since `closed_ids` is a comma-separated string, using it in a single `/browse/{closed_ids}` path will confuse users with a non-functional link. If you want clickable links, either emit one URL per ID or log the base JIRA URL separately and keep the IDs as a list/string.
</issue_to_address>

Sourcery is free for open source - if you like our reviews please consider sharing them ✨
Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.

Comment on lines +306 to 314
if ctx.settings.jira_show_url:
ctx.logger.debug(
f"Checking {jira_issue_key} "
f"({ctx.settings.jira_url}/browse/{jira_issue_key})")
else:
ctx.logger.debug(f"Checking {jira_issue_key}")

is_new = False
if jira_handler.newa_id(action) in jira_issue["description"] \
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

issue (bug_risk): Building a single JIRA URL from a comma-separated list of IDs will produce an invalid link.

Since closed_ids is a comma-separated string, using it in a single /browse/{closed_ids} path will confuse users with a non-functional link. If you want clickable links, either emit one URL per ID or log the base JIRA URL separately and keep the IDs as a list/string.

@kkaarreell
Copy link
Copy Markdown
Collaborator

Hi @bajertom , what output are you typically consuming? newa list should provide full URLs of Jira issues and RP launches in the output and my terminal let's me to open them using right mouse click -> open link. Is this the case for you as well?

@bajertom
Copy link
Copy Markdown
Contributor Author

bajertom commented Mar 10, 2026

The output that newa continuously sends to terminal, like this one:

[tbajer:newa]$ newa-stage event --erratum 159087 jira --issue-config ~/newa-configuration/issue-config/errata.yaml schedule --arch x86_64 execute report
03/10/2026 04:00:08 PM Using --state-dir=/var/tmp/newa/run-453
[2026-03-10 16:00:30,394] [event   ] Erratum release RHEL-9.8.0.GA transformed to a compose RHEL-9.8.0-Nightly
[2026-03-10 16:00:30,397] [event   ] Artifact job E: 159087 @ RHEL-9.8.0.GA written to /var/tmp/newa/run-453/event-159087-RHEL-9.8.0.GA.yaml
[2026-03-10 16:00:30,399] [jira    ] Discovered event job E: 159087 @ RHEL-9.8.0.GA in /var/tmp/newa/run-453/event-159087-RHEL-9.8.0.GA.yaml
[2026-03-10 16:00:35,112] [jira    ] Initialized Jira handler
[2026-03-10 16:00:35,113] [jira    ] Processing errata_epic
[2026-03-10 16:00:37,129] [jira    ] Checking SWM-6829
[2026-03-10 16:00:38,672] [jira    ] Issue SWM-6829 re-used
[2026-03-10 16:00:38,672] [jira    ] Processing task_package_mode
[2026-03-10 16:00:50,622] [jira    ] New issue SWM-6833 created
[2026-03-10 16:00:50,627] [jira    ] Jira job J: 159087 @ RHEL-9.8.0.GA - SWM-6833 written to /var/tmp/newa/run-453/jira-159087-RHEL-9.8.0.GA-SWM-6833.yaml
[2026-03-10 16:00:50,632] [jira    ] Skipped, issue action is irrelevant (ERRATUM.components | join(' ') is match('redhat-rpm-config|rpm|dnf-plugins-core|librhsm|yum|yum-utils|microdnf|createrepo$'))
[2026-03-10 16:00:50,635] [schedule] Discovered jira job J: 159087 @ RHEL-9.8.0.GA - SWM-6833 in /var/tmp/newa/run-453/jira-159087-RHEL-9.8.0.GA-SWM-6833.yaml
[2026-03-10 16:00:50,636] [schedule] 1 requests have been generated
[2026-03-10 16:00:52,043] [schedule] Schedule job S: 159087 @ RHEL-9.8.0.GA - SWM-6833 / REQ-1.1.1 written to /var/tmp/newa/run-453/schedule-159087-RHEL-9.8.0.GA-SWM-6833-REQ-1.1.1.yaml
[2026-03-10 16:00:52,393] [execute ] Discovered schedule job S: 159087 @ RHEL-9.8.0.GA - SWM-6833 / REQ-1.1.1 in /var/tmp/newa/run-453/schedule-159087-RHEL-9.8.0.GA-SWM-6833-REQ-1.1.1.yaml
[2026-03-10 16:00:53,821] [execute ] Created RP launch 9b97cab3-97bf-49b6-9431-f2cbfd18b81a for issue SWM-6833
[2026-03-10 16:00:53,827] [execute ] Schedule job S: 159087 @ RHEL-9.8.0.GA - SWM-6833 / REQ-1.1.1 written to /var/tmp/newa/run-453/schedule-159087-RHEL-9.8.0.GA-SWM-6833-REQ-1.1.1.yaml
[2026-03-10 16:00:55,459] [execute ] Jira issue SWM-6833 was updated with a comment about initiated test execution
[2026-03-10 16:00:55,502] [execute ] schedule-159087-RHEL-9.8.0.GA-SWM-6833-REQ-1.1.1.yaml: processing TF request...
[2026-03-10 16:00:55,502] [execute ] schedule-159087-RHEL-9.8.0.GA-SWM-6833-REQ-1.1.1.yaml: initiating TF request
[2026-03-10 16:00:57,184] [execute ] schedule-159087-RHEL-9.8.0.GA-SWM-6833-REQ-1.1.1.yaml: TF request filed with uuid 49e157a8-939b-414b-ac6f-f5c76b78be68
[2026-03-10 16:00:57,188] [execute ] Execute job X: 159087 @ RHEL-9.8.0.GA - SWM-6833 / REQ-1.1.1 written to /var/tmp/newa/run-453/execute-159087-RHEL-9.8.0.GA-SWM-6833-REQ-1.1.1.yaml
[2026-03-10 16:01:57,797] [execute ] Execute job X: 159087 @ RHEL-9.8.0.GA - SWM-6833 / REQ-1.1.1 written to /var/tmp/newa/run-453/execute-159087-RHEL-9.8.0.GA-SWM-6833-REQ-1.1.1.yaml
[2026-03-10 16:01:57,797] [execute ] schedule-159087-RHEL-9.8.0.GA-SWM-6833-REQ-1.1.1.yaml: TF request 49e157a8-939b-414b-ac6f-f5c76b78be68 envs: RHEL-9.8.0-Nightly/x86_64 state: running

You're right about newa list - I was not using that and there is a link to jira. But still - when I want to get quickly to the artifacts page to check the pipeline.log whether something works/errors out, I have to wait until the run is finished using newa list or alt+shift+D on the TF UUID to get there from the raw output.

Feel free to close it as a Won't fix, I could debug in hatch development environment using this code change.

@kkaarreell
Copy link
Copy Markdown
Collaborator

Feel free to close it as a Won't fix, I could debug in hatch development environment using this code change.

I am OK adding the functionality, I would just prefer to have a single option (something like use_urls_in_logs) that would impact both Jira issues, ET, Report Portal and GitLab.
Also, I would like it to support staging instances as well, I believe this should be possible.

log(f'TF request {tf_request.uuid} envs: {envs} state: {state}')
if ctx.settings.tf_show_url:
log(
f'TF request {execute_job.execution.artifacts_url}'
Copy link
Copy Markdown
Collaborator

@kkaarreell kkaarreell Mar 11, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If a request hasn't been scheduled yet, there won't be any artifacts URL. See line 118.
This is in fact the reason we are logging only UUIDs because early after submitting we have only URL to TF request API and not artifacts URL.

if ctx.settings.jira_show_url:
ctx.logger.info(
f"Relevant issues {closed_ids} "
f"({ctx.settings.jira_url}/browse/{closed_ids}) found but already closed")
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

closed_ids is a list, this won't create a functional link.

@kkaarreell kkaarreell changed the title Allow clickable TF/jira links [WIP] Allow clickable TF/jira links Mar 13, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants