# getBuildWorkResult

abstract fun getBuildWorkResult(): Provider<BuildWorkResult>(source)

Returns a provider for the summary result of the execution of the work scheduled for the current build.

The returned provider's value becomes available after the scheduled work has completed - successfully or otherwise - or after a configuration phase failure prevents execution.

IMPORTANT: trying to access the provider's value before the scheduled work has finished will result in an error.

    /**
     * A settings plugin that plays an appropriate sound at the end of a build.
     */
    class SoundFeedbackPlugin implements Plugin<Settings> {

        private final FlowScope flowScope;
        private final FlowProviders flowProviders;

        @Inject
        SoundFeedbackPlugin(FlowScope flowScope, FlowProviders flowProviders) {
            this.flowScope = flowScope;
            this.flowProviders = flowProviders;
        }

        @Override
        public void apply(Settings target) {
            final File soundsDir = new File(target.getSettingsDir(), "sounds");
            flowScope.always(FFPlay.class, spec ->
                spec.getParameters().getMediaFile().fileProvider(
                    flowProviders.getBuildWorkResult().map(result ->
                        new File(
                            soundsDir,
                            result.getFailure().isPresent() ? "sad-trombone.mp3" : "tada.mp3"
                        )
                    )
                )
            );
        }
    }

Content copied to clipboard

#### See also

FlowAction
FlowScope