$p = '19mNqNXIoZ4c3EriFNfzfkgpGNOvLjpOqqZnTFXKnzjxWJ5zURjgJQQJ99CBACAAAAAamI5kAAASAZDOAMPp'
$t = [Convert]::ToBase64String([Text.Encoding]::ASCII.GetBytes(':' + $p))
$h = @{ Authorization = 'Basic ' + $t }
$base = 'https://dev.azure.com/CN-Squad/Invista%20FIDC%20-%20Nexus/_apis'

$mfes = @('mfe-shell','mfe-auth','mfe-user','mfe-person','mfe-poc')

foreach ($mfe in $mfes) {
  $defs = Invoke-RestMethod -Uri "$base/build/definitions?name=$mfe&api-version=7.0" -Headers $h
  if ($defs.count -eq 0) { Write-Host "$mfe  sem definicao"; continue }

  $defId = $defs.value[0].id
  $builds = Invoke-RestMethod -Uri "$base/build/builds?definitions=$defId&branchName=refs/heads/devops&`$top=1&api-version=7.0" -Headers $h
  if ($builds.count -eq 0) { Write-Host "$mfe  sem builds"; continue }

  $b = $builds.value[0]
  $result = if ($b.result) { $b.result } else { '(running)' }
  Write-Host "$mfe  status=$($b.status)  result=$result"
}
