mirror of
https://github.com/Alfresco/alfresco-ng2-components.git
synced 2026-09-09 18:03:21 +00:00
make shorter
This commit is contained in:
@@ -295,8 +295,8 @@ async function deployMissingApps(tag?: string, envs?: string[]) {
|
|||||||
|
|
||||||
if (retry < MAX_RETRY) {
|
if (retry < MAX_RETRY) {
|
||||||
retry++;
|
retry++;
|
||||||
await forceUndeployFailedApps(failingApps, environmentId)
|
await Promise.all(envs?.map(envId => forceUndeployFailedApps(failingApps, envId)) || [forceUndeployFailedApps(failingApps)]);
|
||||||
await sleep(TIME);
|
await sleep(5000);
|
||||||
await deployMissingApps(tag);
|
await deployMissingApps(tag);
|
||||||
} else {
|
} else {
|
||||||
process.exit(1);
|
process.exit(1);
|
||||||
@@ -368,20 +368,17 @@ async function checkIfAppIsReleased(missingApps: any [], tag?: string, envs?: st
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (noError) {
|
if (noError) {
|
||||||
await checkDescriptorExist(currentAbsentApp.name);
|
await Promise.all(envs?.map(envId => processEnv(TIME, currentAbsentApp, projectRelease, envId)) || [processEnv(TIME, currentAbsentApp, projectRelease)]);
|
||||||
await sleep(TIME);
|
|
||||||
|
|
||||||
if (envs && envs.length > 0) {
|
|
||||||
for (const envId of envs){
|
|
||||||
await deployWithPayload(currentAbsentApp, projectRelease, envId);
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
await deployWithPayload(currentAbsentApp, projectRelease);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
async function processEnv(time: any, currentAbsentApp: any, projectRelease: any, envId?: string) {
|
||||||
|
await checkDescriptorExist(currentAbsentApp.name, envId);
|
||||||
|
await sleep(time);
|
||||||
|
await deployWithPayload(currentAbsentApp, projectRelease, envId);
|
||||||
|
}
|
||||||
|
|
||||||
async function deployWithPayload(currentAbsentApp: any, projectRelease: any, envId?: string) {
|
async function deployWithPayload(currentAbsentApp: any, projectRelease: any, envId?: string) {
|
||||||
const deployPayload = {
|
const deployPayload = {
|
||||||
name: currentAbsentApp.name,
|
name: currentAbsentApp.name,
|
||||||
@@ -392,13 +389,13 @@ async function deployWithPayload(currentAbsentApp: any, projectRelease: any, env
|
|||||||
environmentId: envId
|
environmentId: envId
|
||||||
};
|
};
|
||||||
|
|
||||||
logger.info(`Deploying ${currentAbsentApp.name} ${envId ? 'on env: ' + envId : '' }`);
|
logger.info(`Deploying ${currentAbsentApp.name} ${envId ? 'on env: ' + envId : ''}`);
|
||||||
await deploy(deployPayload);
|
await deploy(deployPayload);
|
||||||
logger.info(`Deployed ${currentAbsentApp.name} ${envId ? 'on env: ' + envId : '' }`);
|
logger.info(`Deployed ${currentAbsentApp.name} ${envId ? 'on env: ' + envId : ''}`);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
async function deleteDescriptor(appName: any [], environmentId?: string) {
|
async function deleteDescriptor(appName: any [], envId?: string) {
|
||||||
const url = `${args.host}/deployment-service/v1/descriptors/${appName}`;
|
const url = `${args.host}/deployment-service/v1/descriptors/${appName}`;
|
||||||
|
|
||||||
const pathParams = {};
|
const pathParams = {};
|
||||||
@@ -406,7 +403,7 @@ async function deleteDescriptor(appName: any [], environmentId?: string) {
|
|||||||
const headerParams = {};
|
const headerParams = {};
|
||||||
const formParams = {};
|
const formParams = {};
|
||||||
const bodyParam = {
|
const bodyParam = {
|
||||||
environmentId: environmentId
|
environmentId: envId
|
||||||
};
|
};
|
||||||
const contentTypes = ['application/json'];
|
const contentTypes = ['application/json'];
|
||||||
const accepts = ['application/json'];
|
const accepts = ['application/json'];
|
||||||
@@ -419,7 +416,7 @@ async function deleteDescriptor(appName: any [], environmentId?: string) {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
async function forceUndeployFailedApps(failedApps: any [], environmentId?: string) {
|
async function forceUndeployFailedApps(failedApps: any [], envId?: string) {
|
||||||
|
|
||||||
for (const appName in failedApps) {
|
for (const appName in failedApps) {
|
||||||
logger.error(`Force undeploy app in failed status ${appName}`);
|
logger.error(`Force undeploy app in failed status ${appName}`);
|
||||||
@@ -431,7 +428,7 @@ async function forceUndeployFailedApps(failedApps: any [], environmentId?: strin
|
|||||||
const headerParams = {};
|
const headerParams = {};
|
||||||
const formParams = {};
|
const formParams = {};
|
||||||
const bodyParam = {
|
const bodyParam = {
|
||||||
environmentId: environmentId
|
environmentId: envId
|
||||||
};
|
};
|
||||||
const contentTypes = ['application/json'];
|
const contentTypes = ['application/json'];
|
||||||
const accepts = ['application/json'];
|
const accepts = ['application/json'];
|
||||||
@@ -444,7 +441,7 @@ async function forceUndeployFailedApps(failedApps: any [], environmentId?: strin
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
async function checkDescriptorExist(name: string) {
|
async function checkDescriptorExist(name: string, envId?: string) {
|
||||||
logger.info(`Check descriptor ${name} exist in the list `);
|
logger.info(`Check descriptor ${name} exist in the list `);
|
||||||
const descriptorList = await getDescriptors();
|
const descriptorList = await getDescriptors();
|
||||||
|
|
||||||
@@ -452,7 +449,7 @@ async function checkDescriptorExist(name: string) {
|
|||||||
for (const descriptor of descriptorList.list.entries) {
|
for (const descriptor of descriptorList.list.entries) {
|
||||||
if (descriptor.entry.name === name) {
|
if (descriptor.entry.name === name) {
|
||||||
if (descriptor.entry.deployed === false) {
|
if (descriptor.entry.deployed === false) {
|
||||||
await deleteDescriptor(descriptor.entry.name);
|
await deleteDescriptor(descriptor.entry.name, envId);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user