@houmak/minerva-mcp-server
Version:
Minerva Model Context Protocol (MCP) Server for Microsoft 365 and Azure integrations
179 lines (178 loc) • 6.13 kB
JavaScript
import { logger } from '../logger.js';
export class AzureDevOpsManager {
organization;
project;
token;
baseUrl;
constructor(config) {
this.organization = config.organization;
this.project = config.project;
this.token = config.token;
this.baseUrl = `https://dev.azure.com/${this.organization}/${this.project}`;
}
/**
* Créer un pipeline Azure DevOps
*/
async createPipeline(config) {
logger.info('Creating Azure DevOps pipeline', { name: config.name });
try {
// Simulation de création de pipeline
const pipeline = {
id: `pipeline-${Date.now()}`,
name: config.name,
repository: config.repository,
branch: config.branch,
yamlPath: config.yamlPath,
status: 'created',
createdDate: new Date().toISOString()
};
logger.info('Pipeline created successfully', { pipelineId: pipeline.id });
return pipeline;
}
catch (error) {
const errorMessage = error instanceof Error ? error.message : String(error);
logger.error('Failed to create pipeline', { error: errorMessage });
throw error;
}
}
/**
* Déclencher un build
*/
async triggerBuild(pipelineId, branch = 'main') {
logger.info('Triggering build', { pipelineId, branch });
try {
const build = {
id: `build-${Date.now()}`,
status: 'inProgress',
result: 'none',
startTime: new Date()
};
logger.info('Build triggered successfully', { buildId: build.id });
return build;
}
catch (error) {
logger.error('Failed to trigger build', { error: error instanceof Error ? error.message : String(error) });
throw error;
}
}
/**
* Récupérer les work items
*/
async getWorkItems(query) {
logger.info('Getting work items', { query });
try {
// Simulation de récupération de work items
const workItems = [
{
id: 1,
title: 'Implement Sprint 4 features',
type: 'Task',
state: 'Active',
assignedTo: 'Developer'
},
{
id: 2,
title: 'Add Azure DevOps integration',
type: 'User Story',
state: 'New',
assignedTo: 'Product Owner'
}
];
logger.info('Work items retrieved successfully', { count: workItems.length });
return workItems;
}
catch (error) {
logger.error('Failed to get work items', { error: error instanceof Error ? error.message : String(error) });
throw error;
}
}
/**
* Créer une pull request
*/
async createPullRequest(repo, source, target, title) {
logger.info('Creating pull request', { repo, source, target });
try {
const pr = {
id: `pr-${Date.now()}`,
title: title || `Merge ${source} into ${target}`,
sourceBranch: source,
targetBranch: target,
status: 'active',
createdBy: 'System'
};
logger.info('Pull request created successfully', { prId: pr.id });
return pr;
}
catch (error) {
logger.error('Failed to create pull request', { error: error instanceof Error ? error.message : String(error) });
throw error;
}
}
/**
* Récupérer les builds récents
*/
async getRecentBuilds(pipelineId, count = 10) {
logger.info('Getting recent builds', { pipelineId, count });
try {
const builds = [
{
id: 'build-1',
status: 'completed',
result: 'succeeded',
startTime: new Date(Date.now() - 3600000),
finishTime: new Date(Date.now() - 1800000)
},
{
id: 'build-2',
status: 'completed',
result: 'failed',
startTime: new Date(Date.now() - 7200000),
finishTime: new Date(Date.now() - 5400000)
}
];
logger.info('Recent builds retrieved successfully', { count: builds.length });
return builds;
}
catch (error) {
logger.error('Failed to get recent builds', { error: error instanceof Error ? error.message : String(error) });
throw error;
}
}
/**
* Obtenir les statistiques du projet
*/
async getProjectStats() {
logger.info('Getting project statistics');
try {
const stats = {
totalWorkItems: 150,
activeWorkItems: 45,
completedWorkItems: 105,
totalBuilds: 25,
successfulBuilds: 22,
failedBuilds: 3,
successRate: 88.0
};
logger.info('Project statistics retrieved successfully');
return stats;
}
catch (error) {
logger.error('Failed to get project statistics', { error: error instanceof Error ? error.message : String(error) });
throw error;
}
}
/**
* Vérifier la disponibilité du service
*/
async isAvailable() {
try {
// Simulation de vérification de disponibilité
logger.info('Checking Azure DevOps availability');
return true;
}
catch (error) {
logger.error('Azure DevOps not available', { error: error instanceof Error ? error.message : String(error) });
return false;
}
}
}