Add RoG (GitLab) comment support with jira, execute, and report triggers#317
Merged
kkaarreell merged 1 commit intomainfrom Feb 12, 2026
Merged
Add RoG (GitLab) comment support with jira, execute, and report triggers#317kkaarreell merged 1 commit intomainfrom
kkaarreell merged 1 commit intomainfrom
Conversation
Reviewer's GuideImplements RoG (GitLab) merge request private comment support parallel to existing Errata Tool comments, driven by new RoGCommentTrigger configuration and a rog_enable_comments setting, while also fixing Jira-related robustness issues and iterator exhaustion in jira_cmd. Sequence diagram for JIRA command with RoG JIRA trigger commentssequenceDiagram
actor User
participant CLI as jira_cmd
participant Ctx as CLIContext
participant JH as JiraHandler
participant RoG as RoGTool
participant GL as GitLab
User->>CLI: run jira --config ...
CLI->>Ctx: load_artifact_jobs()
Ctx-->>CLI: iterator of ArtifactJob
CLI->>CLI: artifact_jobs = list(iterator)
CLI->>CLI: has_erratum = any(EventType.ERRATUM)
CLI->>CLI: has_rog = any(EventType.ROG)
CLI->>RoG: create(token)
RoG-->>CLI: RoGTool instance
loop for each ArtifactJob
CLI->>JH: create IssueHandler
CLI->>CLI: _process_issue_config(..., jira_handler, et, rog)
CLI->>CLI: _process_issue_action(..., et, rog)
CLI->>CLI: _find_or_create_issue(...)
CLI->>JH: refresh_issue(action, issue)
JH-->>CLI: trigger_comment bool
alt Errata Tool JIRA trigger
CLI->>CLI: _handle_erratum_comment_for_jira(..., trigger_comment)
end
alt RoG JIRA trigger
CLI->>CLI: _handle_rog_comment_for_jira(..., trigger_comment)
CLI->>RoG: add_comment(artifact_job.rog.id, comment)
RoG->>GL: get(project).mergerequests.get(number)
RoG->>GL: notes.create(body, internal=true)
GL-->>RoG: note created
end
end
Sequence diagram for EXECUTE and REPORT commands with RoG triggerssequenceDiagram
actor User
participant ExecCLI as execute_cmd
participant ReportCLI as report_cmd
participant Ctx as CLIContext
participant RP as ReportPortal
participant JIRA as Jira
participant RoG as RoGTool
participant GL as GitLab
User->>ExecCLI: run execute
ExecCLI->>Ctx: get_jira_connection()
ExecCLI->>RP: initialize_rp_connection(ctx)
ExecCLI->>RoG: create(token) if rog_enable_comments
ExecCLI->>ExecCLI: _process_rp_launches_and_jira_updates(ctx, rp, et, rog, mapping)
loop for each jira_id, jobs
ExecCLI->>RP: create_launch(job)
RP-->>ExecCLI: launch_url
ExecCLI->>JIRA: update issue status and fields
alt EXECUTE trigger enabled and job.rog set
ExecCLI->>ExecCLI: _add_rog_comment_for_execution(...)
ExecCLI->>JIRA: issue(jira_id).fields.summary
JIRA-->>ExecCLI: issue_summary
ExecCLI->>RoG: add_comment(job.rog.id, comment including launch_url)
RoG->>GL: mergerequests.get(number).notes.create(internal=true)
end
end
User->>ReportCLI: run report
ReportCLI->>Ctx: get_jira_connection()
ReportCLI->>RP: initialize_rp_connection(ctx)
ReportCLI->>RoG: create(token) if rog_enable_comments
ReportCLI->>ReportCLI: _process_jira_id_reports(ctx, jira_id, execute_jobs, rp, jira_connection, et, rog)
loop for each jira_id
ReportCLI->>RP: _get_rp_launch_details(execute_jobs)
RP-->>ReportCLI: launch_uuid, launch_url
alt REPORT trigger enabled and execute_job.rog set
ReportCLI->>ReportCLI: _add_rog_comment_for_report(...)
ReportCLI->>JIRA: issue(jira_id).fields.summary
JIRA-->>ReportCLI: issue_summary
ReportCLI->>RoG: add_comment(execute_job.rog.id, comment)
RoG->>GL: mergerequests.get(number).notes.create(internal=true)
end
end
Class diagram for RoG comment configuration and modelsclassDiagram
class Settings {
bool et_enable_comments
bool et_deduplicate_releases
bool rog_enable_comments
string rog_token
}
class RoGCommentTrigger {
<<enum>>
JIRA
EXECUTE
REPORT
}
class ErratumCommentTrigger {
<<enum>>
JIRA
EXECUTE
REPORT
}
class Issue {
list~ErratumCommentTrigger~ erratum_comment_triggers
list~RoGCommentTrigger~ rog_comment_triggers
string action_id
}
class IssueAction {
list~ErratumCommentTrigger~ erratum_comment_triggers
list~RoGCommentTrigger~ rog_comment_triggers
string id
string environment
}
class RoGTool {
string url
string token
connection_factory() gitlab.Gitlab
add_comment(mr_url string, comment string) void
parse_mr_project_and_number(url string) tuple~string,string~
}
Settings --> RoGTool : configures
Issue --> RoGCommentTrigger : uses
IssueAction --> RoGCommentTrigger : uses
Issue --> ErratumCommentTrigger : uses
IssueAction --> ErratumCommentTrigger : uses
RoGTool --> RoGCommentTrigger : used for triggers via config
File-Level Changes
Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
There was a problem hiding this comment.
Hey - I've found 2 issues, and left some high level feedback:
- Consider adding basic exception handling and logging around the GitLab API calls in
RoGTool.add_commentso that a failure to post a merge request note does not crash the entire NEWA workflow. - The new RoG comment helper functions (
_handle_rog_comment_for_jira,_add_rog_comment_for_execution,_add_rog_comment_for_report) duplicate comment text construction; factoring shared templates or a small formatter utility would make future changes to wording or formatting less error-prone. - The additional debug logging in
JiraHandler.refresh_issueis quite verbose; you may want to reduce or consolidate some of these messages to keep logs readable in normal debug runs.
Prompt for AI Agents
Please address the comments from this code review:
## Overall Comments
- Consider adding basic exception handling and logging around the GitLab API calls in `RoGTool.add_comment` so that a failure to post a merge request note does not crash the entire NEWA workflow.
- The new RoG comment helper functions (`_handle_rog_comment_for_jira`, `_add_rog_comment_for_execution`, `_add_rog_comment_for_report`) duplicate comment text construction; factoring shared templates or a small formatter utility would make future changes to wording or formatting less error-prone.
- The additional debug logging in `JiraHandler.refresh_issue` is quite verbose; you may want to reduce or consolidate some of these messages to keep logs readable in normal debug runs.
## Individual Comments
### Comment 1
<location> `newa/cli/jira_helpers.py:347-353` </location>
<code_context>
processed_actions[action.id] = new_issue
short_sleep()
- trigger_erratum_comment = jira_handler.refresh_issue(action, new_issue)
+ # Refresh issue description to add/update NEWA ID unless --no-newa-id is used
+ if not no_newa_id:
+ ctx.logger.debug(f"Calling refresh_issue for {new_issue.id}")
+ trigger_comment = jira_handler.refresh_issue(action, new_issue)
+ ctx.logger.debug(f"refresh_issue returned: {trigger_comment}")
+ else:
+ ctx.logger.info("Skipping issue refresh due to --no-newa-id flag")
ctx.logger.info(f"Issue {new_issue} re-used")
</code_context>
<issue_to_address>
**issue (bug_risk):** Skipping `refresh_issue` when `--no-newa-id` is set also prevents NEWA label updates and comment triggering on reused issues.
Previously, `refresh_issue` always ran for reused issues, ensuring NEWA labels were kept in sync and allowing its return value to drive erratum/RoG comments. With the new guard on `--no-newa-id`, reused issues will no longer get NEWA label updates, and `trigger_comment` stays `False`, so `_handle_erratum_comment_for_jira` / `_handle_rog_comment_for_jira` will never run even when configured.
If the flag’s intent is only to hide the NEWA ID in the description, consider decoupling these behaviors (e.g., still calling `refresh_issue` but skipping only the description change, or adding a separate control for label/comment behavior).
</issue_to_address>
### Comment 2
<location> `README.md:364` </location>
<code_context>
- `jira` - Adds a comment when a Jira issue is initially 'adopted' by NEWA (either created or taken over due to `jira --map-issue` parameter).
- `execute` - Adds a comment when automated tests are initiated by NEWA.
- `report` - Adds a comment when automated tests results are reported by NEWA.
+ - `rog_comment_triggers` - For specified triggers, provides an update in a RoG (GitLab) merge request through a comment. This functionality needs to be enabled also in the `newa` configuration file through `[rog] enable_comments = 1`. The following triggers are currently supported:
+ - `jira` - Adds a comment when a Jira issue is initially 'adopted' by NEWA (either created or taken over due to `jira --map-issue` parameter).
</code_context>
<issue_to_address>
**suggestion (typo):** Adjust "automated tests results" to the more natural "automated test results".
Suggested implementation:
```
- `report` - Adds a comment when automated test results are reported by NEWA.
```
```
- `report` - Adds a comment when automated test results are reported by NEWA.
```
</issue_to_address>Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.
This commit implements GitLab merge request commenting functionality parallel to the existing Errata Tool comment feature, allowing NEWA to add private/internal notes to GitLab MRs at key workflow stages. Changes: - Add RoGCommentTrigger enum with JIRA, EXECUTE, and REPORT values - Add rog_comment_triggers field to Issue and IssueAction models - Add rog_enable_comments setting to Settings model (newa.conf) - Implement add_comment() method in RoGTool for creating internal notes - Add RoGCommentTrigger to YAML representer for proper serialization - Add JIRA trigger: comment when issue is created or mapped via --map-issue - Add EXECUTE trigger: comment when test execution is initiated - Add REPORT trigger: comment when test execution completes - Fix iterator exhaustion bug in jira_cmd.py (convert to list before multiple iterations) - Fix refresh_issue() to handle Jira issues with None descriptions - Use double newlines in GitLab comments for proper Markdown rendering - Update README documentation with rog_comment_triggers configuration The RoG commenting feature mirrors the Errata Tool implementation: - Controlled by [rog] enable_comments setting in newa.conf - Configured per-action via rog_comment_triggers list in issue-config - Comments are added as private/internal GitLab notes - Supports conditional initialization based on event type Fixes two critical bugs discovered during implementation: 1. jira_cmd.py: Iterator exhaustion when checking event types before processing artifact_jobs loop (convert iterator to list) 2. jira_service.py: refresh_issue() failed on issues with None description (convert None to empty string before processing) 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
984bf1c to
8ce5e36
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This commit implements GitLab merge request commenting functionality parallel to the existing Errata Tool comment feature, allowing NEWA to add private/internal notes to GitLab MRs at key workflow stages.
Changes:
The RoG commenting feature mirrors the Errata Tool implementation:
Fixes two critical bugs discovered during implementation:
🤖 Generated with Claude Code
Summary by Sourcery
Add configurable GitLab (RoG) merge request commenting tied to Jira workflow events and improve Jira integration robustness.
New Features:
Bug Fixes:
Enhancements: