GitLab Datasource Plugin
A comprehensive Dify datasource plugin that enables seamless integration with GitLab, allowing you to access projects, issues, merge requests, and files from both GitLab.com and self-hosted GitLab instances.
🚀 Features
Core Functionality
- 🏗️ Project Access: Browse and download files from public and private projects
- 🎯 Issues & Merge Requests: Access issue and MR content with full comment threads
- 📁 File Management: Access any file in your GitLab projects with automatic content processing
- 🔍 Smart Content Processing: Automatic markdown rendering and content extraction
- ⚡ Real-time Updates: Access the latest project activity and content
Authentication & Security
- 🔐 Multiple Authentication Methods:
- Personal Access Tokens (PAT)
- OAuth 2.0 with automatic refresh
- 🌐 Self-hosted Support: Full compatibility with self-hosted GitLab instances
- 🛡️ Secure Credential Handling: Encrypted storage and transmission of credentials
- 🚦 Rate Limit Management: Intelligent rate limit detection and automatic retry
Advanced Features
- 📊 Metadata Extraction: Comprehensive project, issue, and MR metadata
- 💬 Comment Threading: Full access to discussion threads and notes
- 🏷️ Label & Tag Support: Access to project labels and categorization
- 🌳 Branch Navigation: Support for different branches and file versions
- 📈 Activity Tracking: Access to project activity and timeline data
📋 Supported Content Types
Project Files
- Documentation: Markdown (), reStructuredText (), AsciiDoc ()
- Code Files: Python (), JavaScript (), TypeScript (), Java (), C++ (), and more
- Configuration: YAML (, ), JSON (), XML (), TOML ()
- Data: CSV (), SQL (), notebooks ()
- Web: HTML (), CSS (), SCSS ()
GitLab Content
- Projects: Complete project information, README files, and repository structure
- Issues: Issue descriptions, comments, labels, assignees, and status tracking
- Merge Requests: MR descriptions, discussions, file changes, and approval status
- Wiki Pages: Project wiki content and documentation
- Snippets: Code snippets and gists
🛠️ Installation
Prerequisites
- Dify platform (version 1.0.0 or higher)
- GitLab account with appropriate permissions
- Python 3.12+ environment
Quick Setup
-
Install the Plugin
-
Configure Authentication
Choose one of the following authentication methods:
Option A: Personal Access Token (Recommended for development)
- Go to GitLab → Settings → Access Tokens
- Create a new token with scopes: , ,
- Copy the token for configuration
Option B: OAuth 2.0 (Recommended for production)
- Go to GitLab → Settings → Applications
- Create a new application with redirect URI from Dify
- Note the Client ID and Client Secret
⚙️ Configuration
Personal Access Token Setup
- In Dify, navigate to Settings → Datasources
- Find GitLab and click Connect
- Choose Personal Access Token authentication
- Fill in the configuration:
OAuth 2.0 Setup
-
GitLab Application Configuration:
-
Dify Configuration:
Self-hosted GitLab
For self-hosted GitLab instances:
📖 Usage Examples
Basic Project Access
Issue and MR Access
Advanced Filtering
🔧 API Reference
Content Types
Response Format
🚨 Troubleshooting
Common Issues
Authentication Failed (401)
Rate Limit Exceeded (429)
Project Not Found (404)
Self-hosted GitLab Issues
Debugging
Enable debug logging:
Permission Requirements
Minimum Required Scopes:
- : Access user profile information
- : Access project files and metadata
- : Access issues, merge requests, and other API endpoints
For Private Projects:
- Ensure token/OAuth app has access to private repositories
- Verify project membership and role permissions
🔒 Security Considerations
Token Security
- Use Personal Access Tokens with minimal required scopes
- Regularly rotate access tokens (recommended: every 90 days)
- Monitor token usage in GitLab audit logs
Network Security
- Use HTTPS for all GitLab communications
- For self-hosted instances, ensure proper SSL/TLS configuration
- Consider IP whitelisting for enhanced security
Data Privacy
- Plugin accesses only explicitly requested content
- No persistent storage of GitLab credentials
- All data transmission is encrypted
- See PRIVACY.md for detailed privacy policy
🎯 Performance Optimization
Caching Strategy
- Content is cached temporarily to reduce API calls
- Metadata caching for improved response times
- Automatic cache invalidation on content updates
Rate Limit Management
- Intelligent request batching
- Automatic retry with exponential backoff
- Rate limit monitoring and alerts
Large Project Handling
- Efficient pagination for large project listings
- Streaming for large file downloads
- Memory-efficient processing for bulk operations
🔄 Version History
v0.3.0 (Current)
- ✅ OAuth 2.0 authentication support
- ✅ Self-hosted GitLab compatibility
- ✅ Enhanced merge request support
- ✅ Improved error handling and debugging
- ✅ Advanced metadata extraction
v0.2.0
- ✅ Issue and merge request access
- ✅ Comment thread support
- ✅ File content extraction
- ✅ Basic project browsing
v0.1.0
- ✅ Initial release
- ✅ Personal Access Token authentication
- ✅ Basic project access
- ✅ Simple file retrieval
📞 Support
Documentation
Community Support
Enterprise Support
For enterprise installations and custom requirements:
📄 License
This plugin is released under the MIT License. See LICENSE for details.
🤝 Contributing
We welcome contributions! Please see CONTRIBUTING.md for guidelines.
- Fork the repository
- Create a feature branch
- Make your changes
- Add tests for new functionality
- Submit a pull request
Made with ❤️ for the Dify community