sendBuildSummary method
Send build completion summary
Implementation
Future<void> sendBuildSummary({
required String client,
required String platform,
required String type,
required String version,
required bool success,
required Duration buildTime,
String? errorMessage,
File? artifactFile,
}) async {
_debugLog('=== BUILD SUMMARY ===');
_debugLog('Success: $success');
_debugLog('Type: $type');
_debugLog('Artifact file: ${artifactFile?.path ?? 'null'}');
_debugLog('File exists: ${artifactFile?.existsSync() ?? false}');
final fields = <String, String>{
'Client': client,
'Platform': platform,
'Type': type.toUpperCase(),
'Version': version,
'Build Time': '${buildTime.inMinutes}m ${buildTime.inSeconds % 60}s',
'Status': success ? 'SUCCESS' : 'FAILED',
};
if (errorMessage != null) {
fields['Error'] = errorMessage;
}
// Upload artifact if it's an APK and build was successful
if (success && type.toLowerCase() == 'apk' && artifactFile != null) {
Logger.info('Uploading APK artifact to Slack...');
final uploadSuccess = await uploadFile(
file: artifactFile,
title: '📱 ${client}_$version.apk',
comment: 'Fresh build ready for testing! 🚀\n\n'
'• Client: $client\n'
'• Version: $version\n'
'• Platform: $platform\n'
'• Build time: ${buildTime.inMinutes}m ${buildTime.inSeconds % 60}s',
);
if (uploadSuccess) {
Logger.success('APK uploaded to Slack successfully!');
} else {
Logger.warning('Failed to upload APK artifact to Slack.');
}
} else {
_debugLog('Skipping APK upload:');
_debugLog(' - Success: $success');
_debugLog(' - Type is APK: ${type.toLowerCase() == 'apk'}');
_debugLog(' - File provided: ${artifactFile != null}');
if (success && type.toLowerCase() != 'apk') {
Logger.info(
'APK upload skipped — build type is "$type" (only APKs are uploaded)');
} else if (!success) {
Logger.info('APK upload skipped — build was not successful.');
} else if (artifactFile == null) {
Logger.warning('APK upload skipped — no artifact file provided.');
}
}
}