Being able to load a dynamic file location (#7456)

This commit is contained in:
Maurizio Vitale
2022-01-19 12:07:27 +00:00
committed by GitHub
parent 4058a71e3f
commit 0a18ec61a9
2 changed files with 14 additions and 10 deletions

View File

@@ -41,6 +41,7 @@ export interface ConfigArgs {
clientId: string; clientId: string;
host: string; host: string;
identityHost: boolean; identityHost: boolean;
tag: string;
} }
export const AAE_MICROSERVICES = [ export const AAE_MICROSERVICES = [
@@ -240,7 +241,7 @@ function getAlfrescoJsApiInstance(configArgs: ConfigArgs) {
return new AlfrescoApi(config); return new AlfrescoApi(config);
} }
async function deployMissingApps() { async function deployMissingApps(tag?: string) {
const deployedApps = await getApplicationByStatus(''); const deployedApps = await getApplicationByStatus('');
findMissingApps(deployedApps.list.entries); findMissingApps(deployedApps.list.entries);
findFailingApps(deployedApps.list.entries); findFailingApps(deployedApps.list.entries);
@@ -253,14 +254,14 @@ async function deployMissingApps() {
process.exit(1); process.exit(1);
} else if (absentApps.length > 0) { } else if (absentApps.length > 0) {
logger.warn(`Missing apps: ${JSON.stringify(absentApps)}`); logger.warn(`Missing apps: ${JSON.stringify(absentApps)}`);
await checkIfAppIsReleased(absentApps); await checkIfAppIsReleased(absentApps, tag);
} else { } else {
const reset = '\x1b[0m', green = '\x1b[32m'; const reset = '\x1b[0m', green = '\x1b[32m';
logger.info(`${green}All the apps are correctly deployed${reset}`); logger.info(`${green}All the apps are correctly deployed${reset}`);
} }
} }
async function checkIfAppIsReleased(missingApps: any []) { async function checkIfAppIsReleased(missingApps: any [], tag?: string) {
const projectList = await getProjects(); const projectList = await getProjects();
let TIME = 5000; let TIME = 5000;
let noError = true; let noError = true;
@@ -278,7 +279,7 @@ async function checkIfAppIsReleased(missingApps: any []) {
logger.warn('Missing project: Create the project for ' + currentAbsentApp.name); logger.warn('Missing project: Create the project for ' + currentAbsentApp.name);
try { try {
projectRelease = await importProjectAndRelease(currentAbsentApp); projectRelease = await importProjectAndRelease(currentAbsentApp, tag);
} catch (error) { } catch (error) {
logger.info(`error status ${error.status}`); logger.info(`error status ${error.status}`);
@@ -348,8 +349,10 @@ async function checkDescriptorExist(name: string) {
return false; return false;
} }
async function importProjectAndRelease(app: any) { async function importProjectAndRelease(app: any, tag?: string) {
await getFileFromRemote(app.file_location, app.name); const appLocationReplaced = app.file_location(tag);
logger.warn('App fileLocation ' + appLocationReplaced);
await getFileFromRemote(appLocationReplaced, app.name);
logger.warn('Project imported ' + app.name); logger.warn('Project imported ' + app.name);
const projectRelease = await importAndReleaseProject(`${app.name}.zip`); const projectRelease = await importAndReleaseProject(`${app.name}.zip`);
await deleteLocalFile(`${app.name}`); await deleteLocalFile(`${app.name}`);
@@ -427,6 +430,7 @@ async function main(configArgs: ConfigArgs) {
.option('--modelerPassword [type]', 'modeler password') .option('--modelerPassword [type]', 'modeler password')
.option('--devopsUsername [type]', 'username of a user with role ACTIVIT_DEVOPS') .option('--devopsUsername [type]', 'username of a user with role ACTIVIT_DEVOPS')
.option('--devopsPassword [type]', 'devops password') .option('--devopsPassword [type]', 'devops password')
.option('--tag [type]', 'tag name of the codebase')
.parse(process.argv); .parse(process.argv);
if (process.argv.includes('-h') || process.argv.includes('--help')) { if (process.argv.includes('-h') || process.argv.includes('--help')) {
@@ -459,7 +463,7 @@ async function main(configArgs: ConfigArgs) {
process.exit(1); process.exit(1);
}); });
await deployMissingApps(); await deployMissingApps(args.tag);
} else { } else {
logger.error('The environment is not up'); logger.error('The environment is not up');
process.exit(1); process.exit(1);

View File

@@ -19,7 +19,7 @@
export const ACTIVITI_CLOUD_APPS: any = { export const ACTIVITI_CLOUD_APPS: any = {
SUB_PROCESS_APP: { SUB_PROCESS_APP: {
name: 'subprocessapp', name: 'subprocessapp',
file_location: 'https://github.com/Alfresco/alfresco-ng2-components/blob/develop/e2e/resources/activiti7/subprocessapp.zip?raw=true', file_location: (TAG = 'develop') => `https://github.com/Alfresco/alfresco-ng2-components/blob/${TAG}/e2e/resources/activiti7/subprocessapp.zip?raw=true`,
processes: { processes: {
processchild: 'processchild', processchild: 'processchild',
processparent: 'processparent' processparent: 'processparent'
@@ -31,7 +31,7 @@ export const ACTIVITI_CLOUD_APPS: any = {
}, },
CANDIDATE_BASE_APP: { CANDIDATE_BASE_APP: {
name: 'candidatebaseapp', name: 'candidatebaseapp',
file_location: 'https://github.com/Alfresco/alfresco-ng2-components/blob/develop/e2e/resources/activiti7/candidatebaseapp.zip?raw=true', file_location: (TAG = 'develop') => `https://github.com/Alfresco/alfresco-ng2-components/blob/${TAG}/e2e/resources/activiti7/candidatebaseapp.zip?raw=true`,
processes: { processes: {
candidateUserProcess: 'candidateuserprocess', candidateUserProcess: 'candidateuserprocess',
candidateGroupProcess: 'candidategroupprocess', candidateGroupProcess: 'candidategroupprocess',
@@ -74,7 +74,7 @@ export const ACTIVITI_CLOUD_APPS: any = {
}, },
SIMPLE_APP: { SIMPLE_APP: {
name: 'simpleapp', name: 'simpleapp',
file_location: 'https://github.com/Alfresco/alfresco-ng2-components/blob/develop/e2e/resources/activiti7/simpleapp.zip?raw=true', file_location: (TAG = 'develop') => `https://github.com/Alfresco/alfresco-ng2-components/blob/${TAG}/e2e/resources/activiti7/simpleapp.zip?raw=true`,
processes: { processes: {
processwithvariables: 'processwithvariables', processwithvariables: 'processwithvariables',
simpleProcess: 'simpleprocess', simpleProcess: 'simpleprocess',