missions api2 gitea
This commit is contained in:
parent
a33048ccf6
commit
4aaf4e8016
@ -141,28 +141,36 @@ export class IntegrationService {
|
|||||||
await new Promise(resolve => setTimeout(resolve, 3000));
|
await new Promise(resolve => setTimeout(resolve, 3000));
|
||||||
|
|
||||||
// Step 4: Create Gitea repository (Consider this non-critical)
|
// Step 4: Create Gitea repository (Consider this non-critical)
|
||||||
try {
|
// Only create if Gite or Calcul services are selected
|
||||||
console.log('Starting Gitea repository creation...');
|
if (mission.services &&
|
||||||
const repoData = await this.giteaService.createRepository(mission);
|
(mission.services.includes('Gite') || mission.services.includes('Calcul'))) {
|
||||||
if (repoData && repoData.html_url) {
|
try {
|
||||||
giteaRepositoryUrl = repoData.html_url;
|
console.log('Starting Gitea repository creation...');
|
||||||
} else {
|
const repoData = await this.giteaService.createRepository(mission);
|
||||||
giteaRepositoryUrl = this.giteaService.getRepositoryUrl(
|
if (repoData && repoData.html_url) {
|
||||||
mission.name
|
giteaRepositoryUrl = repoData.html_url;
|
||||||
.toLowerCase()
|
} else {
|
||||||
.replace(/\s+/g, '-')
|
giteaRepositoryUrl = this.giteaService.getRepositoryUrl(
|
||||||
.replace(/[^a-z0-9-]/g, '')
|
mission.name
|
||||||
);
|
.toLowerCase()
|
||||||
}
|
.replace(/\s+/g, '-')
|
||||||
console.log(`Gitea repository created at: ${giteaRepositoryUrl}`);
|
.replace(/[^a-z0-9-]/g, '')
|
||||||
integrationStatus.gitea.success = true;
|
);
|
||||||
integrationStatus.gitea.url = giteaRepositoryUrl;
|
}
|
||||||
} catch (giteaError) {
|
console.log(`Gitea repository created at: ${giteaRepositoryUrl}`);
|
||||||
console.error('Error creating Gitea repository:', giteaError);
|
integrationStatus.gitea.success = true;
|
||||||
integrationStatus.gitea.success = false;
|
integrationStatus.gitea.url = giteaRepositoryUrl;
|
||||||
integrationStatus.gitea.error = giteaError instanceof Error ? giteaError.message : String(giteaError);
|
} catch (giteaError) {
|
||||||
|
console.error('Error creating Gitea repository:', giteaError);
|
||||||
|
integrationStatus.gitea.success = false;
|
||||||
|
integrationStatus.gitea.error = giteaError instanceof Error ? giteaError.message : String(giteaError);
|
||||||
|
|
||||||
// Don't set criticalFailure - Gitea is non-critical
|
// Don't set criticalFailure - Gitea is non-critical
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
console.log('Skipping Gitea repository creation - neither Gite nor Calcul services selected');
|
||||||
|
integrationStatus.gitea.success = false;
|
||||||
|
integrationStatus.gitea.error = 'Skipped - service not selected';
|
||||||
}
|
}
|
||||||
|
|
||||||
// Update the mission with the integration IDs (only for successful integrations)
|
// Update the mission with the integration IDs (only for successful integrations)
|
||||||
@ -300,17 +308,26 @@ export class IntegrationService {
|
|||||||
try {
|
try {
|
||||||
// Extract owner and repo from URL
|
// Extract owner and repo from URL
|
||||||
const urlParts = giteaRepositoryUrl.split('/');
|
const urlParts = giteaRepositoryUrl.split('/');
|
||||||
const owner = urlParts[urlParts.length - 2];
|
// Make sure we have enough parts in the URL before accessing array elements
|
||||||
const repo = urlParts[urlParts.length - 1];
|
if (urlParts.length >= 2) {
|
||||||
|
const owner = urlParts[urlParts.length - 2];
|
||||||
|
const repo = urlParts[urlParts.length - 1];
|
||||||
|
|
||||||
console.log(`Attempting to delete Gitea repository: ${owner}/${repo}`);
|
console.log(`Attempting to delete Gitea repository: ${owner}/${repo}`);
|
||||||
const giteaSuccess = await this.giteaService.deleteRepository(owner, repo);
|
const giteaSuccess = await this.giteaService.deleteRepository(owner, repo);
|
||||||
rollbackStatuses.gitea = giteaSuccess;
|
rollbackStatuses.gitea = giteaSuccess;
|
||||||
console.log(`Gitea repository deletion ${giteaSuccess ? 'successful' : 'failed'}: ${owner}/${repo}`);
|
console.log(`Gitea repository deletion ${giteaSuccess ? 'successful' : 'failed'}: ${owner}/${repo}`);
|
||||||
|
} else {
|
||||||
|
console.log(`Invalid Gitea repository URL format: ${giteaRepositoryUrl}`);
|
||||||
|
}
|
||||||
} catch (giteaError) {
|
} catch (giteaError) {
|
||||||
console.error('Error during Gitea rollback:', giteaError);
|
console.error('Error during Gitea rollback:', giteaError);
|
||||||
console.log(`⚠️ Note: Gitea repository at ${giteaRepositoryUrl} may need to be deleted manually`);
|
console.log(`⚠️ Note: Gitea repository at ${giteaRepositoryUrl} may need to be deleted manually`);
|
||||||
}
|
}
|
||||||
|
} else {
|
||||||
|
console.log('No Gitea repository was created, skipping rollback');
|
||||||
|
// Mark as successful since there's nothing to delete
|
||||||
|
rollbackStatuses.gitea = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Provide a summary of rollback operations
|
// Provide a summary of rollback operations
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user