feat(tests): on-hold button with reason modal, Jira comment + On Hold transition
Aegis CI / lint-and-test (push) Waiting to run
Snyk Security Scan / Python vulnerabilities (backend) (push) Waiting to run
Snyk Security Scan / npm vulnerabilities (frontend) (push) Waiting to run
Snyk Security Scan / Docker image vulnerabilities (backend) (push) Waiting to run
Aegis CI / lint-and-test (push) Waiting to run
Snyk Security Scan / Python vulnerabilities (backend) (push) Waiting to run
Snyk Security Scan / npm vulnerabilities (frontend) (push) Waiting to run
Snyk Security Scan / Docker image vulnerabilities (backend) (push) Waiting to run
This commit is contained in:
@@ -633,6 +633,73 @@ def push_test_event(
|
||||
)
|
||||
|
||||
|
||||
# ---------------------------------------------------------------------------
|
||||
# On-hold Jira notification
|
||||
# ---------------------------------------------------------------------------
|
||||
|
||||
|
||||
def push_hold_event(
|
||||
db: Session,
|
||||
test,
|
||||
actor,
|
||||
*,
|
||||
resuming: bool = False,
|
||||
reason: str | None = None,
|
||||
) -> None:
|
||||
"""Post an on-hold / resume comment to the Jira issue linked to *test*.
|
||||
|
||||
Non-fatal — any Jira error is logged and swallowed.
|
||||
"""
|
||||
if not has_jira_configured(actor, db):
|
||||
return
|
||||
|
||||
link = (
|
||||
db.query(JiraLink)
|
||||
.filter(
|
||||
JiraLink.entity_type == JiraLinkEntityType.test,
|
||||
JiraLink.entity_id == test.id,
|
||||
)
|
||||
.first()
|
||||
)
|
||||
if not link:
|
||||
return
|
||||
|
||||
try:
|
||||
jira = get_user_jira_client(actor, db)
|
||||
ts = datetime.utcnow().strftime("%Y-%m-%d %H:%M UTC")
|
||||
|
||||
if resuming:
|
||||
comment = (
|
||||
f"h3. ▶ Test Resumed\n\n"
|
||||
f"*Resumed by:* {actor.username}\n"
|
||||
f"*At:* {ts}\n\n"
|
||||
f"_The test has been taken off hold and is active again._"
|
||||
)
|
||||
try:
|
||||
jira.set_issue_status(link.jira_issue_key, "In Progress")
|
||||
except Exception as exc_t:
|
||||
logger.warning("Could not transition %s off hold: %s", link.jira_issue_key, exc_t)
|
||||
else:
|
||||
comment = (
|
||||
f"h3. ⏸ Test Placed On Hold\n\n"
|
||||
f"*Placed on hold by:* {actor.username}\n"
|
||||
f"*At:* {ts}\n"
|
||||
f"*Reason:* {reason or 'No reason provided'}\n\n"
|
||||
f"_This test has been paused. No action required until it is resumed._"
|
||||
)
|
||||
try:
|
||||
jira.set_issue_status(link.jira_issue_key, "On Hold")
|
||||
except Exception as exc_t:
|
||||
logger.warning("Could not transition %s to On Hold: %s", link.jira_issue_key, exc_t)
|
||||
|
||||
jira.issue_add_comment(link.jira_issue_key, comment)
|
||||
link.last_synced_at = datetime.utcnow()
|
||||
db.flush()
|
||||
logger.info("Posted hold event to Jira %s (resuming=%s)", link.jira_issue_key, resuming)
|
||||
except Exception as exc:
|
||||
logger.warning("Failed to push hold event for test %s: %s", test.id, exc, exc_info=True)
|
||||
|
||||
|
||||
# ---------------------------------------------------------------------------
|
||||
# Legacy / generic helpers (kept for existing routes)
|
||||
# ---------------------------------------------------------------------------
|
||||
|
||||
Reference in New Issue
Block a user