Skip to content

srinithivadivelu/FinalYear-Git-agent

Repository files navigation

GitHub-Jira Teams Integration Bot

A comprehensive webhook-based automation bot that integrates GitHub, Jira, and Microsoft Teams to streamline developer workflows and team communication.

🎯 Overview

This project is a Final Year Project demonstrating real-world DevOps automation by connecting multiple platforms:

  • GitHub - Code repository management
  • Jira - Issue tracking and project management
  • Microsoft Teams - Team communication and notifications

The bot automatically sends notifications, generates reports, and monitors project health - reducing manual tracking and improving team visibility.


✨ Key Features

1. Real-Time GitHub Notifications

  • PR Creation/Updates: Instant notifications when pull requests are opened, closed, or merged
  • Review Requests: Alerts when someone is assigned as a reviewer with file change details
  • Review Submissions: Notifications for approvals, change requests, and comments

2. Jira Ticket Integration

  • Ticket Created/Updated: Real-time alerts for new Jira tickets
  • Assignment Tracking: Notifications when tickets are assigned
  • Status Changes: Updates when tickets move through workflow states

3. Automated Weekly Reports

  • Scheduled Reports: Automatically sent every Monday at 9:00 AM
  • Manual Reports: Trigger via API endpoint for on-demand generation
  • Contributor Activity: Shows PRs merged, issues closed, and pending work per developer

4. Stale PR Monitoring

  • Automatic Detection: Identifies PRs open for more than 1 day without activity
  • Daily Checks: Runs every day at 10:00 AM
  • Manual Trigger: Test endpoint available for immediate checking

5. Email Reports with PDF

  • Web Dashboard: Generate and send reports via email
  • PDF Generation: Professional PDF reports with formatted content
  • Multiple Recipients: Send to multiple emails (comma-separated)
  • Individual or Team: Send to specific contributor or entire team

6. AI-Powered PR Summaries

  • Automatic Generation: Uses OpenAI GPT to summarize code changes
  • Smart Analysis: Analyzes PR title, description, and file changes
  • Concise Reports: 1-2 sentence summaries for quick understanding

7. Auto-Reviewer Assignment

  • Smart Selection: Automatically assigns the best reviewer based on code expertise
  • Commit History Analysis: Finds who has contributed most to the changed files
  • Workload Balancing: Considers current review load to distribute work fairly
  • Fallback Strategy: Uses recent contributors if no file-specific experts found
  • Teams Notification: Posts assignment details with reasoning to Teams channel

7. Multi-Platform Notifications

  • Microsoft Teams: Rich MessageCard format with structured information
  • Power Automate Integration: Workflow automation support

🏗️ Architecture

┌─────────────────┐     ┌──────────────────┐     ┌─────────────────┐
│   GitHub        │────▶│                  │────▶│  Microsoft      │
│   Webhooks      │     │  Express Server  │     │  Teams Channel  │
└─────────────────┘     │  (Port 3000)     │     └─────────────────┘
                        │                  │
┌─────────────────┐     │  • GitHub API    │     ┌─────────────────┐
│   Jira          │────▶│  • Jira API      │────▶│  Teams Webhook  │
│   Webhooks      │     │  • Cron Jobs     │     │  (Power Automate)│
└─────────────────┘     │  • Auto-Reviewer │     └─────────────────┘
                        └──────────────────┘
                               │
                               ▼
                        ┌──────────────────┐
                        │  Scheduled Jobs  │
                        │  • Weekly Report │
                        │  • Stale PR Check│
                        └──────────────────┘

📁 Project Structure

FinalYear-Git-agent/
│
├── webhookServer.js      # Main Express server with all endpoints
├── GithubService.js      # GitHub API service functions
├── mcpServer.js          # Model Context Protocol server
├── server.js             # Alternative server entry point
├── reportService.js      # Report generation service
├── teamsService.js       # Microsoft Teams integration service
├── reportGenerator.cjs   # Report generator utility
├── weeklyBot.cjs         # Weekly bot automation
├── githubservice-bot.cjs # GitHub service bot utilities
├── test.js               # Test utilities
├── package.json          # Dependencies and scripts
├── .env                  # Environment variables (not in git)
├── userMap.json          # Maps Teams users to GitHub usernames
├── reports/              # Generated PDF reports directory
│
└── README.md             # This documentation file

🔧 Technologies Used

Technology Purpose
Node.js Runtime environment
Express.js Web server and API endpoints
Axios HTTP client for API calls
node-cron Scheduled job automation
GitHub API Repository data fetching
Jira Webhooks Issue tracking integration
Microsoft Teams Communication platform
OpenAI API AI-powered PR summaries
PDFKit PDF report generation
Nodemailer Email delivery
ngrok Local tunnel for webhook testing

🚀 Setup Instructions

Prerequisites

  • Node.js 18+ installed
  • GitHub account with repository access
  • Jira account with admin access
  • Microsoft Teams with webhook permissions
  • ngrok account (for local development)

1. Clone and Install

# Clone repository
git clone <your-repo-url>
cd FinalYear-Git-agent

# Install dependencies
npm install

2. Environment Configuration

Create .env file:

PORT=3000
GITHUB_TOKEN=ghp_your_github_personal_access_token
REPO_OWNER=your-github-username
REPO_NAME=your-repo-name
TEAMS_WEBHOOK=https://your-teams-webhook-url
TEAMS_WEBHOOKBOT=https://optional-second-webhook-url

# Optional: AI-Powered PR Summaries
OPENAI_API_KEY=sk-your-openai-api-key

# Optional: Email Reports (Gmail)
GMAIL_USER=your-email@gmail.com
GMAIL_PASS=your-app-password

Get GitHub Token:

  1. Go to GitHub → Settings → Developer settings → Personal access tokens
  2. Generate new token with repo scope
  3. Copy token to .env

Get Teams Webhook:

  1. In Teams, go to channel → Connectors → Incoming Webhook
  2. Create webhook and copy URL to .env

3. Start the Server

# Development mode (auto-restart on changes)
npm run dev

# Production mode
npm start

4. Expose Local Server (ngrok)

# Install ngrok if not already installed
# Start ngrok
ngrok http 3000

# Copy the HTTPS URL (e.g., https://abc123.ngrok.io)

🔗 Webhook Configuration

GitHub Webhook Setup

  1. Go to your GitHub repository → Settings → Webhooks
  2. Click Add webhook
  3. Payload URL: https://your-ngrok-url/
  4. Content type: application/json
  5. Events to subscribe:
    • Pull requests
    • Pull request reviews
  6. Click Add webhook

Jira Webhook Setup

  1. Go to Jira → System → Webhooks
  2. Click Create a WebHook
  3. Name: Teams Bot Webhook
  4. URL: https://your-ngrok-url/jira
  5. Events:
    • Issue → created
    • Issue → updated
  6. Click Create

📡 API Endpoints

Endpoint Method Description
/ POST GitHub webhook receiver
/jira POST Jira webhook receiver
/weekly POST Generate manual weekly report
/stale-prs GET/POST Check for stale PRs manually
/dashboard GET Web dashboard for email reports
/send-report POST Generate and email PDF report

Example: Manual Weekly Report

curl -X POST http://localhost:3000/weekly \
  -H "Content-Type: application/json" \
  -d '{"from": "Swetha S", "mentions": [{"name": "Manager"}]}'

Example: Check Stale PRs

# Via browser
curl http://localhost:3000/stale-prs

# Via Postman
POST http://localhost:3000/stale-prs

📅 Scheduled Jobs

Job Schedule Description
Weekly Report Every Monday 9:00 AM Sends contributor activity report
Stale PR Check Every day 10:00 AM Alerts for inactive PRs

🎨 Notification Formats

PR Review Request

👀 REVIEW REQUESTED

@swetha

PR #42: "Fix login bug"
Author: @srinithivadivelu
Files changed: 3 files (+120, -45)

Review now: https://github.com/...

Weekly Report

WEEKLY DEVELOPER REPORT
Monday, March 27, 2026
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━

**Srinithi**
- Fixed login bug
- Updated API docs
Merged: 2 PRs | Raised: 1 PR

**Swetha**
Merged: 3 PRs

━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
Generated by GitHub Weekly Report Bot

Stale PR Alert

STALE PR ALERT

These PRs haven't been updated in 1+ days:

PR #42 - "Database migration" by @arun (5 days old)
Link: https://github.com/...

Please review or merge them!

Auto-Reviewer Assignment

🤖 AUTO-REVIEWER ASSIGNED

PR #42: "Fix login bug"
Author: @srinithi

👤 ASSIGNED REVIEWER: @swetha

📊 SELECTION CRITERIA:
Expertise: 15 pts | 2 pending reviews (adjusted)

📁 FILES CHANGED: 3 files (+120, -45)

🔍 FILE EXPERTISE ANALYSIS:
• src/auth/login.js: @swetha(8), @arun(3)
• src/utils/validator.js: @swetha(5), @john(2)
• tests/auth.test.js: @swetha(4), @mary(2)

💡 Why this reviewer?
This person has significant experience with the code being modified, making them ideal to provide valuable feedback while maintaining code quality standards.

Review now: https://github.com/...

🏢 Real-World Usage Scenario

TechCorp - 50 Developer Team

Morning (9:00 AM)

  • Weekly report automatically posts to #engineering-updates
  • Manager sees Swetha completed 3 PRs, Srinithi has 1 pending

During Work

  • Srinithi creates PR #42 → Bot analyzes changed files
  • Auto-reviewer assigns Swetha (most expertise in auth module)
  • Teams posts assignment with reasoning (file expertise analysis)
  • Swetha approves PR → Srinithi gets confirmation

Daily (10:00 AM)

  • Stale PR check runs
  • Alerts team about 2 PRs sitting for 5 days
  • Manager follows up with developers

Jira Activity

  • New ticket created → Auto-posted to Teams
  • Ticket assigned → Developer gets notification
  • Status changes → Everyone stays updated

🔐 Security Notes

  • Never commit .env file - contains sensitive tokens
  • Rotate GitHub tokens regularly (every 90 days)
  • Use ngrok only for development - production should use proper hosting
  • Validate webhook signatures in production environments

🐛 Troubleshooting

Server not receiving webhooks

  • Check ngrok is running and URL is updated in GitHub/Jira
  • Verify webhook secret (if configured)
  • Check server logs for errors

Teams messages not sending

  • Verify TEAMS_WEBHOOK URL in .env
  • Check webhook is still active in Teams
  • Test with manual curl request

GitHub API errors (401)

  • Token may be expired - generate new one
  • Ensure token has repo scope
  • Check REPO_OWNER and REPO_NAME are correct

📊 Future Enhancements

  • Auto-Reviewer Assignment - Intelligently assigns reviewers based on code expertise
  • CI/CD Build Status Notifications
  • Sprint Velocity Analytics
  • Sentiment Analysis on Comments
  • Multi-Repository Support
  • Web Dashboard with Charts
  • Slack/Discord Integration
  • AI-Powered Insights

🤖 Auto-Reviewer Algorithm

The auto-reviewer feature uses a sophisticated scoring system to select the best reviewer:

How It Works

  1. File Analysis

    • Fetches all files changed in the PR
    • Limits to first 10 files for performance
  2. Expertise Calculation

    • Queries commit history for each changed file
    • Counts commits per author over last 30 commits
    • Weights files by change type (added=1.5x, modified=1.0x, deleted=0.8x)
  3. Workload Balancing

    • Counts pending reviews for each candidate
    • Applies penalty factor: >3 pending = 0.3x, >1 pending = 0.7x
  4. Composite Score

    Score = Expertise × Workload_Penalty
    
  5. Selection

    • Highest composite score wins
    • Fallback to recent contributors if no file experts found

Example Scoring

Reviewer Expertise Pending Reviews Penalty Final Score
@swetha 15 2 0.7 10.5
@arun 12 0 1.0 12.0
@john 8 4 0.3 2.4

In this case, @arun would be selected despite lower expertise because @swetha has a heavy workload.


👨‍🎓 About This Project

Type: Final Year Engineering Project Institution: Sri Ramakrishna Engineering College Developer: Swetha Sivananaitha Perumal Year: 2026

This project demonstrates:

  • REST API integration (GitHub, Jira, Teams)
  • Webhook-based event handling
  • Scheduled automation using cron jobs
  • Real-world DevOps practices
  • Full-stack development skills

📄 License

This project is for educational purposes only.


🤝 Support

For questions or issues, contact:

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors