claimNextJob method

Future<BuildJob?> claimNextJob(
  1. String? customPattern
)

Claims the next queued build job for this platform.

Implementation

Future<BuildJob?> claimNextJob(String? customPattern) async {
  final runsOnPattern =
      customPattern ?? (Platform.isLinux ? '%ubuntu%' : '%macos%');

  final response = await _apiService.claimNextJob({
    'runsOnPattern': runsOnPattern,
  });

  if (response.isSuccessful) {
    final data = response.body;
    if (data == null) return null;
    final jobJson = data['job'] as Map<String, dynamic>?;
    if (jobJson == null) return null;
    return BuildJob.fromJson(jobJson);
  }
  throw HttpException(
    'Failed to claim job from server: ${response.statusCode} ${response.error}',
  );
}