diff --git a/eng/common/build.ps1 b/eng/common/build.ps1 index 8943da242f6e9..b3224ea4a65a0 100644 --- a/eng/common/build.ps1 +++ b/eng/common/build.ps1 @@ -149,7 +149,7 @@ try { if ($restore) { InitializeNativeTools } - + Try-LogClientIpAddress Build } catch { diff --git a/eng/common/build.sh b/eng/common/build.sh index 55b298f16ccd1..91e845d4914eb 100755 --- a/eng/common/build.sh +++ b/eng/common/build.sh @@ -187,6 +187,7 @@ function InitializeCustomToolset { } function Build { + LogClientIp InitializeToolset InitializeCustomToolset diff --git a/eng/common/sdk-task.ps1 b/eng/common/sdk-task.ps1 index b1bca63ab1d82..7ffa3591e9ca0 100644 --- a/eng/common/sdk-task.ps1 +++ b/eng/common/sdk-task.ps1 @@ -83,6 +83,7 @@ try { } if ($restore) { + Try-LogClientIpAddress Build 'Restore' } diff --git a/eng/common/tools.ps1 b/eng/common/tools.ps1 index 5d526c74d518c..6d841b132b2e3 100644 --- a/eng/common/tools.ps1 +++ b/eng/common/tools.ps1 @@ -872,3 +872,21 @@ if (!$disableConfigureToolsetImport) { } } } + +function Try-LogClientIpAddress() +{ + Write-Host "Attempting to log this client's IP for Azure Package feed telemetry purposes" + try + { + $result = Invoke-WebRequest -Uri "http://co1.msedge.net/fdv2/diagnostics.aspx" -UseBasicParsing + $lines = $result.Content.Split([Environment]::NewLine) + $socketIp = $lines | Select-String -Pattern "^Socket IP:.*" + Write-Host $socketIp + $clientIp = $lines | Select-String -Pattern "^Client IP:.*" + Write-Host $clientIp + } + catch + { + Write-Host "Unable to get this machine's effective IP address for logging: $_" + } +} diff --git a/eng/common/tools.sh b/eng/common/tools.sh index 828119be411b3..ce2225ff7019e 100755 --- a/eng/common/tools.sh +++ b/eng/common/tools.sh @@ -399,6 +399,14 @@ function StopProcesses { return 0 } +function LogClientIp () { + echo 'Attempting to log this client''s IP for Azure Package feed telemetry purposes' + echo + if command -v curl > /dev/null; then + curl -s 'http://co1.msedge.net/fdv2/diagnostics.aspx' | grep ' IP: ' + fi +} + function MSBuild { local args=$@ if [[ "$pipelines_log" == true ]]; then