Skip to content

Latest commit

 

History

History
293 lines (222 loc) · 7.42 KB

File metadata and controls

293 lines (222 loc) · 7.42 KB

Allure Failure + Jira Analyzer

FastAPI backend that:

  1. Fetches suites.json or behaviors.json from an Allure report URL
  2. Recursively extracts all failed and broken MFTF tests
  3. Parses each test's name to extract the MFTF ticket ID (e.g. MC-4982, ACP2E-3540)
  4. Searches Jira for open tickets that mention the test name in their title or description

Project structure

allure-jira-analyzer/
├── app/
│   ├── __init__.py
│   ├── config.py       # Settings loaded from .env
│   ├── models.py       # Pydantic request/response models
│   ├── allure.py       # Fetch & parse Allure JSON
│   ├── jira.py         # Jira REST API v2 search + ticket fetch
│   └── main.py         # FastAPI routes
├── requirements.txt
├── .env.example
└── README.md

Setup

Using pip

pip install -r requirements.txt

cp .env.example .env
# Edit .env with your Jira details

Using uv

uv venv
source .venv/bin/activate   # or `.venv\Scripts\activate` on Windows

uv pip install -r requirements.txt

cp .env.example .env
# Edit .env with your Jira details

.env

JIRA_BASE_URL=https://your-org.atlassian.net
JIRA_TOKEN=your_personal_access_token
JIRA_PROJECT_KEYS=MC,AC,ACP2E,MAGETWO,LYNX,ACPT,ACQE,GIT,CABPI

Jira token: Generate at https://your-org.atlassian.net/secure/ViewProfile.jspa → Personal Access Tokens


Run

Using pip/uvicorn directly

uvicorn app.main:app --reload --port 8000

Using uv

uv run uvicorn app.main:app --reload --port 8000

Streamlit UI

A standalone Streamlit frontend is also available — it reuses the same analysis and Jira modules without depending on the FastAPI server.

streamlit run streamlit_app.py

Or with uv:

uv run streamlit run streamlit_app.py

Opens at http://localhost:8501 with tabs for all endpoints.

MCP server (Claude / Cursor)

An MCP server exposes the same analysis flow as tools Claude can call when you paste an Allure URL.

uv run python mcp_server.py

Tools:

Tool Purpose
analyze_allure_report Full report: fetch failures, load test-case JSON, search Jira
generate_build_report Multi-run build report (CE/EE/B2B grouped, Run-1/Run-2)
search_jira Search Jira for a single test name or ticket ID
fetch_jira_ticket Fetch one Jira ticket by key

Predefined prompts (select from Claude's MCP prompt menu after restart):

Prompt Inputs What it does
analyze_allure_report allure_url Instructs Claude to call the analyze tool for one URL
generate_build_report allure_urls (one URL per line) Instructs Claude to call the build report tool and return output verbatim

In Claude Desktop: click the + button → Add from MCP → choose allure-analyzer → pick a prompt → fill in the URL(s).

In Cursor: use MCP prompts from the chat prompt picker (if supported) or paste the same text manually.

Claude Desktop — add to ~/Library/Application Support/Claude/claude_desktop_config.json (see mcp.json.example):

{
  "mcpServers": {
    "allure-analyzer": {
      "command": "/absolute/path/to/allure_analyzer/.venv/bin/python",
      "args": ["/absolute/path/to/allure_analyzer/mcp_server.py"],
      "env": {
        "JIRA_BASE_URL": "https://jira.corp.adobe.com",
        "JIRA_PROJECT_KEYS": "MC,AC,ACP2E,MAGETWO,LYNX"
      }
    }
  }
}

Cursor — merge mcp.json.example into your project's .cursor/mcp.json.

Jira token: set JIRA_TOKEN in .env or mcp.json env, or pass at runtime in chat.

Example — single report (manual prompt):

Analyze this Allure report and summarize failures with Jira tickets:
https://.../allure-report-ee/index.html

Example — build report (manual prompt):

Use generate_build_report and return the output verbatim:

CE: https://.../allure-report-ce/index.html
CE: https://.../allure-report-ce/index.html
EE: https://.../allure-report-ee/index.html
EE: https://.../allure-report-ee/index.html
B2B: https://.../allure-report-b2b/index.html
B2B: https://.../allure-report-b2b/index.html

Swagger UI available at: http://localhost:8000/docs


API Endpoints

POST /analyze

Fetches the Allure JSON from a URL, extracts failures, and searches Jira.

curl -X POST http://localhost:8000/analyze \
  -H "Content-Type: application/json" \
  -d '{
    "allure_url": "https://.../allure-report-ee/data/suites.json",
    "allure_auth_token": "optional-bearer-token-if-report-is-behind-auth",
    "jira_base_url": "https://your-org.atlassian.net",
    "jira_token": "your-token"
  }'

jira_base_url and jira_token are optional if already set in .env

Response:

{
  "summary": {
    "total_tests_scanned": 1248,
    "total_failed": 1,
    "total_broken": 1,
    "total_with_jira_tickets": 2,
    "allure_url": "https://..."
  },
  "results": [
    {
      "test": {
        "name": "MC-4982: Checkout with multiple addresses",
        "status": "failed",
        "uid": "abc123",
        "duration_seconds": 32.0,
        "flaky": false,
        "mftf_test_name": "MC-4982"
      },
      "jira_tickets": [
        {
          "key": "MC-4982",
          "summary": "Checkout fails with multiple addresses after 2.4.7 upgrade",
          "status": "In Progress",
          "url": "https://your-org.atlassian.net/browse/MC-4982",
          "description": "The MFTF test MC-4982 is failing because..."
        }
      ],
      "jira_search_performed": true,
      "jira_error": null
    }
  ]
}

POST /parse

Same as /analyze but accepts the raw Allure JSON in the request body instead of a URL. Useful when the report server blocks server-side fetches (403/CORS).

# Download the JSON in your browser, then POST it
curl -X POST http://localhost:8000/parse \
  -H "Content-Type: application/json" \
  -d '{
    "allure_data": { ...contents of suites.json... },
    "jira_base_url": "https://your-org.atlassian.net",
    "jira_token": "your-token"
  }'

GET /jira/search?test_name=MC-4982

Search Jira for open tickets matching a single MFTF test name.

curl "http://localhost:8000/jira/search?test_name=MC-4982"

GET /jira/ticket/{key}

Fetch a specific Jira ticket by key (mirrors the original JS sample).

curl "http://localhost:8000/jira/ticket/MC-4982"

How Jira search works

For each failed/broken test, the app:

  1. Extracts the MFTF test name from the Allure test title:

    • "MC-4982: Checkout test" → searches for MC-4982
    • "ACP2E-3540: Admin nav test" → searches for ACP2E-3540
    • "[NO TESTCASEID]: Some test name" → searches for Some test name
  2. Builds a JQL query:

    (summary ~ "MC-4982" OR description ~ "MC-4982")
    AND project in ("MC", "AC", "ACP2E", ...)
    AND statusCategory != Done
    ORDER BY created DESC
    
  3. Returns up to 5 matching open tickets per failed test.


Integration with Jenkins / CI

Add a step after your MFTF run to call this API:

# In your Jenkins pipeline (Groovy)
sh """
  curl -s -X POST ${ANALYZER_URL}/analyze \\
    -H 'Content-Type: application/json' \\
    -d '{
      "allure_url": "${ALLURE_REPORT_URL}/data/suites.json",
      "jira_token": "${JIRA_TOKEN}"
    }' > allure_failures.json
  cat allure_failures.json
"""