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) {
print('📤 Uploading APK to Slack...');
_debugLog('Starting APK upload...');
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) {
print('✅ APK uploaded to Slack successfully!');
} else {
print('❌ Failed to upload APK 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') {
print(
'💡 APK upload skipped - build type is $type (only APKs are uploaded)');
} else if (!success) {
print('💡 APK upload skipped - build was not successful');
} else if (artifactFile == null) {
print('❌ APK upload skipped - no artifact file provided');
}
}
}