Skip to content

Latest commit

Β 

History

1 Commit

Folders and files

NameName
Last commit message
Last commit date
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

DevGan - DevOps + Gantt Chart Generator

A Python application that generates Microsoft Project (.MPP) files from Aliyun DevOps platform workitems, creating professional Gantt charts for project management.

πŸš€ Features

βœ… Implemented Features

  • βœ… Chrome Cookie Extraction: Automatically extracts authentication cookies from Chrome browser
  • βœ… DevOps API Integration: Fetches workitems, projects, and hierarchies from Aliyun DevOps platform
  • βœ… MS Project File Generation: Creates professional .XML files that can be imported into MS Project
  • βœ… Open Source Solution: Uses lxml for XML generation instead of proprietary libraries
  • βœ… Bulk Project Processing: Process all accessible projects or selected project lists
  • βœ… Interactive Mode: User-friendly command-line interface with bulk operations support
  • βœ… Project Filtering: Advanced filtering by project IDs, names, codes, keywords, and admin privileges
  • βœ… Comprehensive Configuration: YAML-based configuration management
  • βœ… Logging & Error Handling: Detailed logging for troubleshooting

πŸ“‹ Supported Data Structure

project1 #----------------------------------- API "List projects"
|  |- version1-SS_yy.mm.XXYY.ZZ #------------ API "Project versions"
|  |  |- workitem (εΌ€ε‘ιœ€ζ±‚) #---------------- API "Project workitems", $workitemtypeid is the id of type εΌ€ε‘ιœ€ζ±‚
|  |     |- related workitems (PARENT_SUB) #- API "Query related workitems"
|  |        |- worktime records #------------ API "Workitem workload"
|  |- version2-...
|  |  |- workitem (εΌ€ε‘ιœ€ζ±‚)
|  |     |- related workitems (PARENT_SUB)
|  |        |- worktime records
project2
|  |- version1-SS_yy.mm.XXYY.ZZ
|     |- workitem (εΌ€ε‘ιœ€ζ±‚)
|        |- related workitems (PARENT_SUB)
|           |- worktime records
project3..

πŸ› οΈ Installation

Prerequisites

  • Python 3.8+
  • Chrome browser (for cookie extraction)
  • Access to Aliyun DevOps platform

Setup

  1. Clone and navigate to the project:

    git clone <repository-url>
    cd devgan
  2. Install dependencies:

    pip install -r requirements.txt
  3. Create configuration file:

    python devgan.py --create-config
  4. Edit config.yaml and set your DevOps user ID:

    devops:
      user_id: "your-devops-user-id-here"

πŸ“– Usage

Interactive Mode (Recommended)

Run DevGan in interactive mode for easy project selection:

python devgan.py --interactive

Command Line Options

# Test cookie extraction
python devgan.py --test-cookies

# Test DevOps API connection
python devgan.py --test-connection

# List available projects
python devgan.py --list-projects

# Generate project file for specific project
python devgan.py --project-id PROJECT_ID --output output.xml

# Generate with specific version
python devgan.py --project-id PROJECT_ID --version-id VERSION_ID

# Use custom configuration
python devgan.py --config custom_config.yaml --interactive

Bulk Operations

DevGan supports powerful bulk operations to process multiple projects at once:

# Generate consolidated MS Project XML file for ALL accessible projects
python devgan.py --all-projects

# Generate consolidated MS Project XML file for specific projects
python devgan.py --selected-projects "proj1" "proj2" "proj3"

# Get workitems summary for all accessible projects
python devgan.py --workitems-summary

# Get workitems summary for specific projects
python devgan.py --summary-projects "proj1" "proj2"

# Bulk operations with custom output
python devgan.py --all-projects --output "consolidated_all_projects.xml"
python devgan.py --selected-projects "proj1" "proj2" --output "selected_projects.xml"

Advanced Usage

# Help and all options
python devgan.py --help

# Run with custom user ID
python devgan.py --user-id YOUR_USER_ID --interactive

# Generate for specific project with custom output
python devgan.py \
  --project-id "5a1295737102f79a8ddd1383ad" \
  --version-id "ad33bc8ce45b0ed7dd6d3350ea" \
  --output "my_project.xml"

# Project filtering examples
python devgan.py --filter-project-ids "proj1" "proj2" --list-projects
python devgan.py --filter-project-names "MITD" "DevOps" --interactive
python devgan.py --filter-custom-codes "ADCS" "R2R" --list-projects
python devgan.py --filter-keywords "control" "automation" --interactive
python devgan.py --exclude-project-ids "old_proj1" --admin-only --list-projects
python devgan.py --no-filter --list-projects  # Disable all filtering

# Bulk operations with filtering
python devgan.py --filter-custom-codes "ADCS" "R2R" --all-projects
python devgan.py --admin-only --workitems-summary
python devgan.py --filter-keywords "automation" --selected-projects "proj1" "proj2"

🎯 Project Filtering

DevGan supports comprehensive project filtering to process only specific projects that match your criteria. This is useful when you have access to many projects but only want to work with a subset.

Configuration-based Filtering

Edit config.yaml to set up persistent filtering:

project:
  filter:
    enabled: true
    project_ids: ["proj1", "proj2"]  # Specific project IDs
    project_names: ["MITD", "Control"]  # Partial name matching
    custom_codes: ["ADCS", "R2R"]  # Custom project codes
    keywords: ["automation", "control"]  # Keywords in name/description
    exclude_project_ids: ["old_proj"]  # Projects to exclude
    admin_only: false  # Only projects where user is admin

Command-line Filtering

Override configuration with command-line options:

# Filter by specific project IDs
python devgan.py --filter-project-ids "proj1" "proj2" --list-projects

# Filter by project names (partial matching)
python devgan.py --filter-project-names "MITD" "Control" --interactive

# Filter by custom codes
python devgan.py --filter-custom-codes "ADCS" "R2R" --list-projects

# Filter by keywords in project name or description
python devgan.py --filter-keywords "automation" "control" --interactive

# Exclude specific projects
python devgan.py --exclude-project-ids "old_proj1" "test_proj" --list-projects

# Only projects where user is admin
python devgan.py --admin-only --list-projects

# Disable all filtering (show all accessible projects)
python devgan.py --no-filter --list-projects

# Combine multiple filters
python devgan.py --filter-custom-codes "ADCS" --admin-only --exclude-project-ids "old_proj" --interactive

Filter Logic

  • Include filters (project_ids, project_names, custom_codes, keywords): If any include filter is specified, projects must match at least one criteria
  • Exclude filters (exclude_project_ids): Projects matching exclude criteria are always filtered out
  • Admin filter (admin_only): Only includes projects where the user has admin privileges
  • Filter precedence: Exclude filters take priority over include filters

πŸ”§ Configuration

Edit config.yaml to customize DevGan behavior:

# DevOps platform settings
devops:
  base_url: "https://devops.aliyun.com"
  domain: "devops.aliyun.com"
  user_id: "your-user-id"  # ⚠️ REQUIRED: Set your DevOps user ID
  timeout: 30

# Chrome browser settings
chrome:
  profile_path: ""  # Auto-detect if empty
  cookie_db: "Cookies"

# Project generation settings
project:
  output_dir: "output"
  default_work_hours_per_day: 8
  include_weekends: false
  
  # Project filtering settings
  filter:
    enabled: true
    # Filter by project IDs (empty list means include all projects)
    project_ids: []
    # Filter by project names (supports partial matching)
    project_names: []
    # Filter by custom codes
    custom_codes: []
    # Filter by keywords in project name or description
    keywords: []
    # Exclude projects by IDs
    exclude_project_ids: []
    # Only include projects where user is admin
    admin_only: false

# Logging configuration
logging:
  level: "INFO"  # DEBUG, INFO, WARNING, ERROR

πŸ“ Project Structure

devgan/
β”œβ”€β”€ src/
β”‚   β”œβ”€β”€ __init__.py           # Package initialization
β”‚   β”œβ”€β”€ main.py              # Main application entry point
β”‚   β”œβ”€β”€ config.py            # Configuration management
β”‚   β”œβ”€β”€ cookie_extractor.py  # Chrome cookie extraction
β”‚   β”œβ”€β”€ devops_client.py     # DevOps API client
β”‚   └── project_generator.py # MS Project file generator
β”œβ”€β”€ tests/
β”‚   └── test_devgan.py       # Test cases
β”œβ”€β”€ output/                  # Generated project files
β”œβ”€β”€ config.yaml             # Configuration file
β”œβ”€β”€ requirements.txt        # Python dependencies
β”œβ”€β”€ devgan.py              # Main entry script
└── README.md              # This file

πŸ” How It Works

  1. Cookie Extraction: Automatically extracts authentication cookies from Chrome browser to authenticate with DevOps platform

  2. Data Fetching: Uses DevOps REST APIs to fetch:

    • User information
    • Project lists
    • Project versions
    • Workitems and their hierarchies
    • Workitem relations (PARENT_SUB, ASSOCIATED)
    • Time tracking data
  3. MS Project Generation: Creates professional .XML files with:

    • Task hierarchies based on workitem relations
    • Task dependencies (Finish-to-Start)
    • Duration and work hours from workitem data
    • Priority levels and status mapping
    • Assignee information
    • Rich task notes with descriptions
    • Can be imported directly into Microsoft Project

πŸ“‹ Generated MS Project Features

  • Task Structure: Hierarchical tasks based on workitem relations
  • Dependencies: Automatic dependency creation from PARENT_SUB and ASSOCIATED relations
  • Scheduling: Duration and work hours from DevOps workitem data
  • Status Mapping: DevOps status mapped to MS Project percent complete
  • Priority Levels: Chinese/English priority levels mapped to MS Project priorities
  • Resource Assignment: Assignee information from DevOps
  • Rich Information: Task notes with descriptions, types, and categories

πŸ§ͺ Testing

Run the test suite:

python -m pytest tests/ -v

Or run specific tests:

# Test configuration
python tests/test_devgan.py TestConfig

# Test cookie extraction
python tests/test_devgan.py TestCookieExtractor

# Test project generation
python tests/test_devgan.py TestProjectGenerator

πŸ”§ Troubleshooting

Common Issues

  1. Cookie Extraction Fails

    • Ensure Chrome browser is installed
    • Login to DevOps platform using Chrome
    • Try running Chrome as the same user
  2. DevOps API Connection Fails

    • Check your user ID in config.yaml
    • Verify network connection
    • Ensure cookies are valid (try --test-cookies)
  3. No Projects Listed

    • Verify your user has access to projects
    • Check user permissions in DevOps platform
  4. Project File Generation Fails

    • Ensure output directory exists and is writable
    • Check that workitems exist for the project/version
    • Verify lxml is installed properly

Debug Mode

Enable debug logging for detailed troubleshooting:

logging:
  level: "DEBUG"

Or run with verbose output:

python devgan.py --interactive 2>&1 | tee devgan_debug.log

πŸ“„ Dependencies

  • requests: HTTP client for DevOps API calls
  • lxml: XML generation for MS Project files
  • browser-cookie3: Chrome cookie extraction
  • pyyaml: Configuration file parsing
  • pandas: Data processing
  • python-dateutil: Date/time handling

πŸ“ License

This project is licensed under the MIT License - see the LICENSE file for details.

🀝 Contributing

  1. Fork the repository
  2. Create a feature branch
  3. Make your changes
  4. Add tests for new functionality
  5. Run the test suite
  6. Submit a pull request

πŸ“ž Support

For issues and questions:

  1. Check the troubleshooting section
  2. Review the debug logs
  3. Create an issue on GitHub with detailed information

About

No description, website, or topics provided.

Resources

Stars

1 star

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages