How to use the @atomist/sdm.SdmGoalState.in_process function in @atomist/sdm

To help you get started, we’ve selected a few @atomist/sdm examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github atomist / sdm-core / lib / handlers / events / delivery / goals / FulfillGoalOnRequested.ts View on Github external
};

        const goalScheduler = await findGoalScheduler(goalInvocation, this.configuration);
        if (!!goalScheduler) {
            const start = Date.now();
            const result = await goalScheduler.schedule(goalInvocation);
            if (!!result && result.code !== undefined && result.code !== 0) {
                await updateGoal(ctx, sdmGoal, {
                    state: SdmGoalState.failure,
                    description: `Failed to schedule goal`,
                    url: progressLog.url,
                });
                await reportEndAndClose(result, start, progressLog);
            } else {
                await updateGoal(ctx, sdmGoal, {
                    state: !!result && !!result.state ? result.state : SdmGoalState.in_process,
                    phase: !!result && !!result.phase ? result.phase : "scheduled",
                    description: !!result && !!result.description ? result.description : descriptionFromState(goal, SdmGoalState.in_process, sdmGoal),
                    url: progressLog.url,
                    externalUrls: !!result ? result.externalUrls : undefined,
                });
            }
            return {
                ...result as any,
                // successfully handled event even if goal failed
                code: 0,
            };
        } else {
            delete (sdmGoal as any).id;

            const listeners = [];
github atomist / sdm-core / lib / handlers / events / delivery / goals / FulfillGoalOnRequested.ts View on Github external
const goalScheduler = await findGoalScheduler(goalInvocation, this.configuration);
        if (!!goalScheduler) {
            const start = Date.now();
            const result = await goalScheduler.schedule(goalInvocation);
            if (!!result && result.code !== undefined && result.code !== 0) {
                await updateGoal(ctx, sdmGoal, {
                    state: SdmGoalState.failure,
                    description: `Failed to schedule goal`,
                    url: progressLog.url,
                });
                await reportEndAndClose(result, start, progressLog);
            } else {
                await updateGoal(ctx, sdmGoal, {
                    state: !!result && !!result.state ? result.state : SdmGoalState.in_process,
                    phase: !!result && !!result.phase ? result.phase : "scheduled",
                    description: !!result && !!result.description ? result.description : descriptionFromState(goal, SdmGoalState.in_process, sdmGoal),
                    url: progressLog.url,
                    externalUrls: !!result ? result.externalUrls : undefined,
                });
            }
            return {
                ...result as any,
                // successfully handled event even if goal failed
                code: 0,
            };
        } else {
            delete (sdmGoal as any).id;

            const listeners = [];

            // Prepare cache project listeners for parameters
            if (!!goalInvocation.parameters) {
github atomist / sdm-core / lib / goal / container / k8s.ts View on Github external
try {
                    await prepareInputAndOutput(inputDir, outputDir, gi);
                } catch (e) {
                    const message = `Failed to prepare input and output for goal ${goalEvent.name}: ${e.message}`;
                    progressLog.write(message);
                    return { code: 1, message };
                }
                const secrets = await prepareSecrets(
                    _.merge({}, registration.containers[0], ((gi.parameters || {})["@atomist/sdm/secrets"] || {})), gi);
                if (!!secrets?.files) {
                    for (const file of secrets.files) {
                        await fs.writeFile(file.mountPath, file.value);
                    }
                }

                goalEvent.state = SdmGoalState.in_process;
                return goalEvent;

            });
        }
github atomist / sdm-core / lib / handlers / events / delivery / build / SetStatusOnBuildComplete.ts View on Github external
function buildStatusToSdmGoalState(buildStatus: BuildStatus): SdmGoalState {
    switch (buildStatus) {
        case "passed":
            return SdmGoalState.success;
        case "broken":
        case "failed":
        case "canceled":
            return SdmGoalState.failure;
        default:
            return SdmGoalState.in_process;
    }
}
github atomist / sdm-pack-aspect / lib / aspect / delivery / support / goalListener.ts View on Github external
return async gei => {
        if (gei.goalEvent.state !== SdmGoalState.in_process) {
            const fps = await fingerprintFinder(gei);
            const pili: PushImpactListenerInvocation = {
                ...gei,
                project: undefined,
                impactedSubProject: undefined,
                filesChanged: undefined,
                commit: gei.goalEvent.push.after,
                push: gei.goalEvent.push,
            };
            return publisher(pili, aspects, toArray(fps), {});
        }
        return false;
    };
}
github atomist / sdm-core / lib / pack / k8s / KubernetesJobDeletingGoalCompletionListener.ts View on Github external
return async gi => {
            const goalEvent = gi.completedGoal;

            if (goalEvent.state === SdmGoalState.in_process) {
                return;
            }

            if (goalEvent.state === SdmGoalState.canceled && !(await cancelableGoal(goalEvent, gi.configuration))) {
                return;
            }

            const selector = `atomist.com/goal-set-id=${goalEvent.goalSetId},atomist.com/creator=${sanitizeName(this.sdm.configuration.name)}`;
            let jobs;

            try {
                jobs = await listJobs(selector);
            } catch (e) {
                logger.warn(`Failed to read k8s jobs: ${prettyPrintError(e)}`);
                return;
            }