- Windows
- CentOS_7
- MacOS
+ condition: ne(variables['Build.Reason'], 'Schedule')
queue:
name: DotNetCore-Build
demands:
_PhaseName : ${{ parameters.phaseName }}
_HelixType: build/product
_HelixBuildConfig: $(_BuildConfig)
- ${{ if notIn(variables['Build.Reason'], 'IndividualCI', 'BatchedCI', 'PullRequest') }}:
+ ${{ if ne(variables['System.TeamProject'], 'public') }}:
_HelixSource: official/dotnet/arcade/$(Build.SourceBranch)
- ${{ if eq(parameters.testOnly, 'true') }}:
- _LinuxScript: $(Build.SourcesDirectory)/eng/citest.sh
- ${{ if ne(parameters.testOnly, 'true') }}:
- _LinuxScript: $(Build.SourcesDirectory)/eng/cibuild.sh
- ${{ if in(variables['Build.Reason'], 'IndividualCI', 'BatchedCI', 'PullRequest') }}:
+ ${{ if eq(variables['System.TeamProject'], 'public') }}:
_HelixSource: pr/dotnet/arcade/$(Build.SourceBranch)
+ ${{ if eq(parameters.testOnly, 'true') }}:
+ _LinuxScript: $(Build.SourcesDirectory)/eng/citest.sh
+ ${{ if ne(parameters.testOnly, 'true') }}:
_LinuxScript: $(Build.SourcesDirectory)/eng/cibuild.sh
+ ${{ if eq(variables['Build.Reason'], 'Schedule') }}:
+ ${{ if eq(parameters.agentOs, 'Windows_NT') }}:
+ _DailyTest: -daily-test
+ ${{ if ne(parameters.agentOs, 'Windows_NT') }}:
+ _DailyTest: --daily-test
+ ${{ if ne(variables['Build.Reason'], 'Schedule') }}:
+ _DailyTest: ''
steps:
# Internal only build steps
parameters:
agentOs: ${{ parameters.agentOs }}
steps:
- - script: $(Build.SourcesDirectory)\eng\cibuild.cmd
+ - script: $(Build.SourcesDirectory)\eng\cibuild.cmd $(_DailyTest)
-configuration $(_BuildConfig)
-architecture $(_BuildArch)
-prepareMachine
--docker-image $(_DockerImageName)
--source-directory $(Build.SourcesDirectory)
--container-name diagnostics-$(Build.BuildId)
- $(_LinuxScript)
+ $(_LinuxScript) $(_DailyTest)
--configuration $(_BuildConfig)
--architecture $(_BuildArch)
--prepareMachine
condition: succeeded()
- ${{ if eq(parameters.agentOs, 'Darwin') }}:
- - script: $(Build.SourcesDirectory)/eng/cibuild.sh
+ - script: $(Build.SourcesDirectory)/eng/cibuild.sh $(_DailyTest)
--configuration $(_BuildConfig)
--architecture $(_BuildArch)
--prepareMachine
condition: succeeded()
# Internal only build steps (until publishing artifacts in public CI is supported)
- - template: /eng/common/templates/steps/build-reason.yml
- parameters:
- conditions: not IndividualCI,BatchedCI,PullRequest
- steps:
- - task: PublishBuildArtifacts@1
- displayName: Upload Artifacts
- inputs:
- pathtoPublish: '$(Build.SourcesDirectory)/artifacts/$(_BuildConfig)/$(_PublishArtifacts)'
- artifactName: $(_PhaseName)_$(Agent.JobName)
- condition: and(succeeded(), ne(variables['_PublishArtifacts'], ''))
+ - ${{ if ne(variables['System.TeamProject'], 'public') }}:
+ - task: PublishBuildArtifacts@1
+ displayName: Upload Artifacts
+ inputs:
+ pathtoPublish: '$(Build.SourcesDirectory)/artifacts/$(_BuildConfig)/$(_PublishArtifacts)'
+ artifactName: $(_PhaseName)_$(Agent.JobName)
+ condition: and(succeeded(), ne(variables['_PublishArtifacts'], ''))
- - task: CopyFiles@2
- displayName: Gather Build Logs
- inputs:
- sourceFolder: '$(Build.SourcesDirectory)/artifacts/$(_BuildConfig)/log'
- targetFolder: '$(Build.StagingDirectory)/BuildLogs'
- continueOnError: true
- condition: always()
+ - task: CopyFiles@2
+ displayName: Gather Build Logs
+ inputs:
+ sourceFolder: '$(Build.SourcesDirectory)/artifacts/$(_BuildConfig)/log'
+ targetFolder: '$(Build.StagingDirectory)/BuildLogs'
+ continueOnError: true
+ condition: always()
- - task: CopyFiles@2
- displayName: Gather Test Logs
- inputs:
- sourceFolder: '$(Build.SourcesDirectory)/artifacts/$(_BuildConfig)/TestResults'
- targetFolder: '$(Build.StagingDirectory)/BuildLogs'
- continueOnError: true
- condition: always()
+ - task: CopyFiles@2
+ displayName: Gather Test Logs
+ inputs:
+ sourceFolder: '$(Build.SourcesDirectory)/artifacts/$(_BuildConfig)/TestResults'
+ targetFolder: '$(Build.StagingDirectory)/BuildLogs'
+ continueOnError: true
+ condition: always()
- - task: PublishBuildArtifacts@1
- displayName: Publish Logs to VSTS
- inputs:
- pathtoPublish: '$(Build.StagingDirectory)/BuildLogs'
- artifactName: Logs_$(_PhaseName)_$(Agent.JobName)
- continueOnError: true
- condition: always()
+ - task: PublishBuildArtifacts@1
+ displayName: Publish Logs to VSTS
+ inputs:
+ pathtoPublish: '$(Build.StagingDirectory)/BuildLogs'
+ artifactName: Logs_$(_PhaseName)_$(Agent.JobName)
+ continueOnError: true
+ condition: always()
+++ /dev/null
-[CmdletBinding()]
-param()
-
-Set-StrictMode -Version 2.0
-$ErrorActionPreference = "Stop"
-
-if (($env:Agent_JobStatus -eq 'Succeeded') -or ($env:Agent_JobStatus -eq 'PartiallySucceeded')) {
- $ErrorCount = 0
-} else {
- $ErrorCount = 1
-}
-$WarningCount = 0
-
-try {
- Invoke-RestMethod -Uri "https://helix.dot.net/api/2018-03-14/telemetry/job/build/$env:Helix_WorkItemId/finish?errorCount=$ErrorCount&warningCount=$WarningCount" -Method Post -ContentType "application/json" -Body "" `
- -Headers @{ 'X-Helix-Job-Token'=$env:Helix_JobToken }
-}
-catch {
- Write-Error $_
- Write-Error $_.Exception
- exit 1
-}
+++ /dev/null
-source="${BASH_SOURCE[0]}"
-# resolve $source until the file is no longer a symlink
-while [[ -h "$source" ]]; do
- scriptroot="$( cd -P "$( dirname "$source" )" && pwd )"
- source="$(readlink "$source")"
- # if $source was a relative symlink, we need to resolve it relative to the path where the
- # symlink file was located
- [[ $source != /* ]] && source="$scriptroot/$source"
-done
-scriptroot="$( cd -P "$( dirname "$source" )" && pwd )"
-
-if [ "$AGENT_JOBSTATUS" = "Succeeded" ] || [ "$AGENT_JOBSTATUS" = "PartiallySucceeded" ]; then
- errorCount=0
-else
- errorCount=1
-fi
-warningCount=0
-
-curlResult=`
-/bin/bash $scriptroot/../curl.sh \
- -H 'Content-Type: application/json' \
- -H "X-Helix-Job-Token: $Helix_JobToken" \
- -H 'Content-Length: 0' \
- -X POST -G "https://helix.dot.net/api/2018-03-14/telemetry/job/build/$Helix_WorkItemId/finish" \
- --data-urlencode "errorCount=$errorCount" \
- --data-urlencode "warningCount=$warningCount"
-`
-curlStatus=$?
-
-if [ $curlStatus -ne 0 ]; then
- echo "Failed to Send Build Finish information"
- echo $curlResult
- if /bin/bash "$scriptroot/../../is-vsts.sh"; then
- echo "##vso[task.logissue type=error;sourcepath=telemetry/build/end.sh;code=1;]Failed to Send Build Finish information: $curlResult"
- fi
- exit 1
-fi
-
-exit 0
+++ /dev/null
-[CmdletBinding()]
-param(
- [string]$BuildUri
-)
-
-Set-StrictMode -Version 2.0
-$ErrorActionPreference = "Stop"
-
-
-try {
- $workItemId = Invoke-RestMethod -Uri "https://helix.dot.net/api/2018-03-14/telemetry/job/build?buildUri=$([Net.WebUtility]::UrlEncode($BuildUri))" -Method Post -ContentType "application/json" -Body "" `
- -Headers @{ 'X-Helix-Job-Token'=$env:Helix_JobToken }
-
- $env:Helix_WorkItemId = $workItemId
- if (& "$PSScriptRoot/../../is-vsts.ps1") {
- Write-Host "##vso[task.setvariable variable=Helix_WorkItemId]$env:Helix_WorkItemId"
- }
-}
-catch {
- Write-Error $_
- Write-Error $_.Exception
- exit 1
-}
+++ /dev/null
-source="${BASH_SOURCE[0]}"
-# resolve $source until the file is no longer a symlink
-while [[ -h "$source" ]]; do
- scriptroot="$( cd -P "$( dirname "$source" )" && pwd )"
- source="$(readlink "$source")"
- # if $source was a relative symlink, we need to resolve it relative to the path where the
- # symlink file was located
- [[ $source != /* ]] && source="$scriptroot/$source"
-done
-scriptroot="$( cd -P "$( dirname "$source" )" && pwd )"
-
-while (($# > 0)); do
- lowerI="$(echo $1 | awk '{print tolower($0)}')"
- case $lowerI in
- --build-uri)
- buildUri=$2
- shift 2
- ;;
- *)
- echo "Unknown Arg '$1'"
- exit 1
- ;;
- esac
-done
-
-
-curlResult=`
-/bin/bash $scriptroot/../curl.sh \
- -H 'Content-Type: application/json' \
- -H "X-Helix-Job-Token: $Helix_JobToken" \
- -H 'Content-Length: 0' \
- -X POST -G "https://helix.dot.net/api/2018-03-14/telemetry/job/build" \
- --data-urlencode "buildUri=$buildUri"
-`
-curlStatus=$?
-
-if [ $curlStatus -ne 0 ]; then
- echo "Failed to Send Build Start information"
- echo $curlResult
- if /bin/bash "$scriptroot/../../is-vsts.sh"; then
- echo "##vso[task.logissue type=error;sourcepath=telemetry/build/start.sh;code=1;]Failed to Send Build Start information: $curlResult"
- fi
- exit 1
-fi
-
-export Helix_WorkItemId=`echo $curlResult | xargs echo` # Strip Quotes
-
-if /bin/bash "$scriptroot/../../is-vsts.sh"; then
- echo "##vso[task.setvariable variable=Helix_WorkItemId]$Helix_WorkItemId"
-else
- echo "export Helix_WorkItemId=$Helix_WorkItemId"
-fi
+++ /dev/null
-#runs curl and exits with exit code when http server errors happen
-res=`mktemp`
-httpCode=$(curl --silent --output $res --write-out "%{http_code}" "$@")
-curlCode=$?
-
-if [ ! $curlCode ]; then
- exit $curlCode
-fi
-
-cat $res
-
-if [ $httpCode -gt 299 ] || [ $httpCode -lt 200 ]; then
- exit 1
-else
- exit 0
-fi
+++ /dev/null
-[CmdletBinding()]
-param(
- [string]$QueueId,
- [string]$Source,
- [string]$Type,
- [string]$Build,
- [string]$Attempt,
- [hashtable]$Properties
-)
-
-Set-StrictMode -Version 2.0
-$ErrorActionPreference = "Stop"
-
-
-$jobInfo = [pscustomobject]@{
- QueueId=$QueueId;
- Source=$Source;
- Type=$Type;
- Build=$Build;
- Properties=[pscustomobject]$Properties;
-}
-
-$jobInfoJson = $jobInfo | ConvertTo-Json
-
-try {
- Write-Verbose "Job Info: $jobInfoJson"
- $jobToken = Invoke-RestMethod -Uri "https://helix.dot.net/api/2018-03-14/telemetry/job?access_token=$($env:HelixApiAccessToken)" -Method Post -ContentType "application/json" -Body $jobInfoJson
-
- $env:Helix_JobToken = $jobToken
- if (& "$PSScriptRoot/../is-vsts.ps1") {
- Write-Host "##vso[task.setvariable variable=Helix_JobToken;issecret=true;]$env:Helix_JobToken"
- }
-}
-catch {
- Write-Error $_
- Write-Error $_.Exception
- exit 1
-}
-
+++ /dev/null
-source="${BASH_SOURCE[0]}"
-# resolve $source until the file is no longer a symlink
-while [[ -h "$source" ]]; do
- scriptroot="$( cd -P "$( dirname "$source" )" && pwd )"
- source="$(readlink "$source")"
- # if $source was a relative symlink, we need to resolve it relative to the path where the
- # symlink file was located
- [[ $source != /* ]] && source="$scriptroot/$source"
-done
-scriptroot="$( cd -P "$( dirname "$source" )" && pwd )"
-
-properties=()
-while (($# > 0)); do
- lowerI="$(echo $1 | awk '{print tolower($0)}')"
- case $lowerI in
- --queue-id)
- queueId=$2
- shift 2
- ;;
- --source)
- source=$2
- shift 2
- ;;
- --type)
- type=$2
- shift 2
- ;;
- --build)
- build=$2
- shift 2
- ;;
- --attempt)
- attempt=$2
- shift 2
- ;;
- -p)
- properties+=($2)
- shift 2
- ;;
- *)
- echo "Unknown Arg '$1'"
- exit 1
- ;;
- esac
-done
-
-jobInfo=`mktemp`
-
-cat > $jobInfo <<JobListStuff
-{
- "QueueId": "$queueId",
- "Source": "$source",
- "Type": "$type",
- "Build": "$build",
- "Attempt": "$attempt",
- "Properties": {
- $(printf '%s\n' "${properties[@]}" | sed 's/\([^=]*\)=\(.*\)/"\1":"\2"/' | awk -vORS=, '{ print }' | sed 's/,$//')
- }
-}
-JobListStuff
-
-curlResult=`
- cat $jobInfo |\
- /bin/bash $scriptroot/curl.sh \
- -H 'Content-Type: application/json' \
- -X POST "https://helix.dot.net/api/2018-03-14/telemetry/job?access_token=$HelixApiAccessToken" -d @-`
-curlStatus=$?
-
-if [ $curlStatus -ne 0 ]; then
- echo "Failed To Send Job Start information"
- echo $curlResult
- if /bin/bash "$scriptroot/../is-vsts.sh"; then
- echo "##vso[task.logissue type=error;sourcepath=telemetry/start-job.sh;code=1;]Failed to Send Job Start information: $curlResult"
- fi
- exit 1
-fi
-
-export Helix_JobToken=`echo $curlResult | xargs echo` # Strip Quotes
-
-if /bin/bash "$scriptroot/../is-vsts.sh"; then
- echo "##vso[task.setvariable variable=Helix_JobToken;issecret=true;]$Helix_JobToken"
-else
- echo "export Helix_JobToken=$Helix_JobToken"
-fi
-
-
## Telemetry variables
- # Required: determines whether to run cmd or sh telemetry files
- agentOs: Windows_NT
-
# Optional: enable sending telemetry
- # if enabled, these "variables" must be specified in the variables object
+ # if 'true', these "variables" must be specified in the variables object or as part of the queue matrix
# _HelixBuildConfig - differentiate between Debug, Release, other
# _HelixSource - Example: build/product
# _HelixType - Example: official/dotnet/arcade/$(Build.SourceBranch)
fetchDepth: ${{ parameters.fetchDepth }}
- ${{ if eq(parameters.enableTelemetry, 'true') }}:
- # Remove this condition once telemetry can be sent from public CI
- - ${{ if notIn(variables['Build.Reason'], 'IndividualCI', 'BatchedCI', 'PullRequest') }}:
- - template: /eng/common/templates/steps/telemetry-start.yml
- parameters:
- agentOs: ${{ parameters.agentOs }}
- buildConfig: ${{ parameters.variables._HelixBuildConfig }}
- helixSource: ${{ parameters.variables._HelixSource }}
- helixType: ${{ parameters.variables._HelixType }}
+ - template: /eng/common/templates/steps/telemetry-start.yml
+ parameters:
+ buildConfig: $(_HelixBuildConfig)
+ helixSource: $(_HelixSource)
+ helixType: $(_HelixType)
# Run provided build steps
- ${{ parameters.steps }}
+ - ${{ if eq(parameters.enableMicrobuild, 'true') }}:
+ # Internal only resources
+ - ${{ if ne(variables['System.TeamProject'], 'public') }}:
+ - task: MicroBuildCleanup@1
+ displayName: Execute Microbuild cleanup tasks
+ condition: and(always(), in(variables['_SignType'], 'real', 'test'), eq(variables['Agent.Os'], 'Windows_NT'))
+ env:
+ TeamName: $(_TeamName)
+
- ${{ if eq(parameters.enableTelemetry, 'true') }}:
- # Remove this condition once telemetry can be sent from public CI
- - ${{ if notIn(variables['Build.Reason'], 'IndividualCI', 'BatchedCI', 'PullRequest') }}:
- - template: /eng/common/templates/steps/telemetry-end.yml
- parameters:
- agentOs: ${{ parameters.agentOs }}
- helixSource: ${{ parameters.variables._HelixSource }}
- helixType: ${{ parameters.variables._HelixType }}
+ - template: /eng/common/templates/steps/telemetry-end.yml
+ parameters:
+ helixSource: $(_HelixSource)
+ helixType: $(_HelixType)
parameters:
- agentOs: Windows_NT
helixSource: 'undefined_defaulted_in_telemetry.yml'
helixType: 'undefined_defaulted_in_telemetry.yml'
steps:
-- template: /eng/common/templates/steps/run-on-unix.yml
- parameters:
- agentOs: ${{ parameters.agentOs }}
- steps:
- - bash: |
- /bin/bash ./telemetry/build/end.sh
- workingDirectory: $(Build.SourcesDirectory)/eng/common
- displayName: Send Build End Telemetry
- env:
- # defined via VSTS variables in start-job.sh
- Helix_JobToken: $(Helix_JobToken)
- Helix_WorkItemId: $(Helix_WorkItemId)
- condition: always()
-- template: /eng/common/templates/steps/run-on-windows.yml
- parameters:
- agentOs: ${{ parameters.agentOs }}
- steps:
- - powershell: |
- ./telemetry/build/end.ps1
- if ($LASTEXITCODE -ne 0) {
- exit $LASTEXITCODE
- }
- workingDirectory: $(Build.SourcesDirectory)/eng/common
- displayName: Send Build End Telemetry
- env:
- # defined via VSTS variables in start-job.ps1
- Helix_JobToken: $(Helix_JobToken)
- Helix_WorkItemId: $(Helix_WorkItemId)
- condition: always()
\ No newline at end of file
+- bash: |
+ if [ "$AGENT_JOBSTATUS" = "Succeeded" ] || [ "$AGENT_JOBSTATUS" = "PartiallySucceeded" ]; then
+ errorCount=0
+ else
+ errorCount=1
+ fi
+ warningCount=0
+
+ # create a temporary file for curl output
+ res=`mktemp`
+
+ curlResult=`
+ curl --verbose --output $res --write-out "%{http_code}"\
+ -H 'Content-Type: application/json' \
+ -H "X-Helix-Job-Token: $Helix_JobToken" \
+ -H 'Content-Length: 0' \
+ -X POST -G "https://helix.dot.net/api/2018-03-14/telemetry/job/build/$Helix_WorkItemId/finish" \
+ --data-urlencode "errorCount=$errorCount" \
+ --data-urlencode "warningCount=$warningCount"`
+ curlStatus=$?
+
+ if [ $curlStatus -eq 0 ]; then
+ if [ $curlResult -gt 299 ] || [ $curlResult -lt 200 ]; then
+ curlStatus=$curlResult
+ fi
+ fi
+
+ if [ $curlStatus -ne 0 ]; then
+ echo "Failed to Send Build Finish information"
+ vstsLogOutput="vso[task.logissue type=error;sourcepath=templates/steps/telemetry-end.yml;code=1;]Failed to Send Build Finish information: $curlStatus"
+ echo "##$vstsLogOutput"
+ exit 1
+ fi
+ displayName: Send Unix Build End Telemetry
+ env:
+ # defined via VSTS variables in start-job.sh
+ Helix_JobToken: $(Helix_JobToken)
+ Helix_WorkItemId: $(Helix_WorkItemId)
+ condition: and(always(), ne(variables['Agent.Os'], 'Windows_NT'))
+- powershell: |
+ if (($env:Agent_JobStatus -eq 'Succeeded') -or ($env:Agent_JobStatus -eq 'PartiallySucceeded')) {
+ $ErrorCount = 0
+ } else {
+ $ErrorCount = 1
+ }
+ $WarningCount = 0
+
+ try {
+ Invoke-RestMethod -Uri "https://helix.dot.net/api/2018-03-14/telemetry/job/build/$env:Helix_WorkItemId/finish?errorCount=$ErrorCount&warningCount=$WarningCount" -Method Post -ContentType "application/json" -Body "" `
+ -Headers @{ 'X-Helix-Job-Token'=$env:Helix_JobToken }
+ }
+ catch {
+ Write-Error $_
+ Write-Error $_.Exception
+ exit 1
+ }
+ displayName: Send Windows Build End Telemetry
+ env:
+ # defined via VSTS variables in start-job.ps1
+ Helix_JobToken: $(Helix_JobToken)
+ Helix_WorkItemId: $(Helix_WorkItemId)
+ condition: and(always(),eq(variables['Agent.Os'], 'Windows_NT'))
parameters:
- agentOs: Windows_NT
helixSource: 'undefined_defaulted_in_telemetry.yml'
helixType: 'undefined_defaulted_in_telemetry.yml'
buildConfig: ''
steps:
-- template: /eng/common/templates/steps/run-on-unix.yml
- parameters:
- agentOs: ${{ parameters.agentOs }}
- steps:
- - task: AzureKeyVault@1
- inputs:
- azureSubscription: 'HelixProd_KeyVault'
- KeyVaultName: HelixProdKV
- SecretsFilter: 'HelixApiAccessToken'
- condition: always()
- - bash: |
- /bin/bash ./telemetry/start-job.sh --source "$Source" --type "$Type" --build "$Build" --queue-id "$QueueId" --attempt "$Attempt" -p "operatingSystem=$OperatingSystem" -p "configuration=$Configuration"
- workingDirectory: $(Build.SourcesDirectory)/eng/common
- displayName: Send Job Start Telemetry
- env:
- HelixApiAccessToken: $(HelixApiAccessToken)
- Source: ${{ parameters.helixSource }}
- Type: ${{ parameters.helixType }}
- Build: $(Build.BuildNumber)
- QueueId: ${{ parameters.agentOs }}
- Attempt: 1
- OperatingSystem: ${{ parameters.agentOs }}
- Configuration: ${{ parameters.buildConfig }}
- condition: always()
- - bash: |
- /bin/bash ./telemetry/build/start.sh --build-uri "$BuildUri"
- workingDirectory: $(Build.SourcesDirectory)/eng/common
- displayName: Send Build Start Telemetry
- env:
- BuildUri: $(System.TaskDefinitionsUri)$(System.TeamProject)/_build/index?buildId=$(Build.BuildId)&_a=summary
- # defined via VSTS variables in start-job.sh
- Helix_JobToken: $(Helix_JobToken)
- condition: always()
+- ${{ if not(eq(variables['System.TeamProject'], 'public')) }}:
+ - task: AzureKeyVault@1
+ inputs:
+ azureSubscription: 'HelixProd_KeyVault'
+ KeyVaultName: HelixProdKV
+ SecretsFilter: 'HelixApiAccessToken'
+ condition: always()
+- bash: |
+ # create a temporary file
+ jobInfo=`mktemp`
-- template: /eng/common/templates/steps/run-on-windows.yml
- parameters:
- agentOs: ${{ parameters.agentOs }}
- steps:
- - task: AzureKeyVault@1
- inputs:
- azureSubscription: 'HelixProd_KeyVault'
- KeyVaultName: HelixProdKV
- SecretsFilter: 'HelixApiAccessToken'
- condition: always()
- - powershell: |
- ./telemetry/start-job.ps1 -Source $env:Source -Type $env:Type -Build $env:Build -QueueId $env:QueueId -Attempt $env:Attempt -Properties @{ operatingSystem=$env:OperatingSystem; configuration=$env:Configuration } -Verbose
- if ($LASTEXITCODE -ne 0) {
- exit $LASTEXITCODE
- }
- workingDirectory: $(Build.SourcesDirectory)/eng/common
- displayName: Send Job Start Telemetry
- env:
- HelixApiAccessToken: $(HelixApiAccessToken)
- Source: ${{ parameters.helixSource }}
- Type: ${{ parameters.helixType }}
- Build: $(Build.BuildNumber)
- QueueId: ${{ parameters.agentOs }}
- Attempt: 1
- OperatingSystem: ${{ parameters.agentOs }}
- Configuration: ${{ parameters.buildConfig }}
- condition: always()
- - powershell: |
- ./telemetry/build/start.ps1 -BuildUri $env:BuildUri
- if ($LASTEXITCODE -ne 0) {
- exit $LASTEXITCODE
- }
- workingDirectory: $(Build.SourcesDirectory)/eng/common
- displayName: Send Build Start Telemetry
- env:
- BuildUri: $(System.TaskDefinitionsUri)$(System.TeamProject)/_build/index?buildId=$(Build.BuildId)&_a=summary
- # defined via VSTS variables in start-job.ps1
- Helix_JobToken: $(Helix_JobToken)
- condition: always()
\ No newline at end of file
+ # write job info content to temporary file
+ cat > $jobInfo <<JobListStuff
+ {
+ "QueueId": "$QueueId",
+ "Source": "$Source",
+ "Type": "$Type",
+ "Build": "$Build",
+ "Attempt": "$Attempt",
+ "Properties": {
+ "operatingSystem": "$OperatingSystem",
+ "configuration": "$Configuration"
+ }
+ }
+ JobListStuff
+
+ # create a temporary file for curl output
+ res=`mktemp`
+
+ accessTokenParameter=''
+ if [[ ! "$HelixApiAccessToken" == "" ]]; then
+ accessTokenParameter="?access_token=$HelixApiAccessToken"
+ fi
+
+ curlResult=`
+ cat $jobInfo |\
+ curl --verbose --output $res --write-out "%{http_code}" \
+ -H 'Content-Type: application/json' \
+ -X POST "https://helix.dot.net/api/2018-03-14/telemetry/job$accessTokenParameter" -d @-`
+ curlStatus=$?
+
+ if [ $curlStatus -eq 0 ]; then
+ if [ $curlResult -gt 299 ] || [ $curlResult -lt 200 ]; then
+ curlStatus=$curlResult
+ fi
+ fi
+
+ curlResult=`cat $res`
+
+ # validate status of curl command
+ if [ $curlStatus -ne 0 ]; then
+ echo "Failed To Send Job Start information"
+ # We have to append the ## vso prefix or vso will pick up the command when it dumps the inline script into the shell
+ vstsLogOutput="vso[task.logissue type=error;sourcepath=telemetry/start-job.sh;code=1;]Failed to Send Job Start information: $curlStatus"
+ echo "##$vstsLogOutput"
+ exit 1
+ fi
+
+ # Set the Helix_JobToken variable
+ export Helix_JobToken=`echo $curlResult | xargs echo` # Strip Quotes
+ echo "##vso[task.setvariable variable=Helix_JobToken;issecret=true;]$Helix_JobToken"
+ displayName: Send Unix Job Start Telemetry
+ env:
+ HelixApiAccessToken: $(HelixApiAccessToken)
+ Source: ${{ parameters.helixSource }}
+ Type: ${{ parameters.helixType }}
+ Build: $(Build.BuildNumber)
+ QueueId: $(Agent.Os)
+ Attempt: 1
+ OperatingSystem: $(Agent.Os)
+ Configuration: ${{ parameters.buildConfig }}
+ condition: and(always(), ne(variables['Agent.Os'], 'Windows_NT'))
+- bash: |
+ res=`mktemp`
+ curlResult=`
+ curl --verbose --output $res --write-out "%{http_code}"\
+ -H 'Content-Type: application/json' \
+ -H "X-Helix-Job-Token: $Helix_JobToken" \
+ -H 'Content-Length: 0' \
+ -X POST -G "https://helix.dot.net/api/2018-03-14/telemetry/job/build" \
+ --data-urlencode "buildUri=$BuildUri"`
+ curlStatus=$?
+
+ if [ $curlStatus -eq 0 ]; then
+ if [ $curlResult -gt 299 ] || [ $curlResult -lt 200 ]; then
+ curlStatus=$curlResult
+ fi
+ fi
+
+ curlResult=`cat $res`
+
+ # validate status of curl command
+ if [ $curlStatus -ne 0 ]; then
+ echo "Failed to Send Build Start information"
+ vstsLogOutput="vso[task.logissue type=error;sourcepath=telemetry/build/start.sh;code=1;]Failed to Send Build Start information: $curlStatus"
+ echo "##$vstsLogOutput"
+ exit 1
+ fi
+
+ export Helix_WorkItemId=`echo $curlResult | xargs echo` # Strip Quotes
+ echo "##vso[task.setvariable variable=Helix_WorkItemId]$Helix_WorkItemId"
+ displayName: Send Unix Build Start Telemetry
+ env:
+ BuildUri: $(System.TaskDefinitionsUri)$(System.TeamProject)/_build/index?buildId=$(Build.BuildId)&_a=summary
+ Helix_JobToken: $(Helix_JobToken)
+ condition: and(always(), ne(variables['Agent.Os'], 'Windows_NT'))
+
+- powershell: |
+ $jobInfo = [pscustomobject]@{
+ QueueId=$env:QueueId;
+ Source=$env:Source;
+ Type=$env:Type;
+ Build=$env:Build;
+ Attempt=$env:Attempt;
+ Properties=[pscustomobject]@{ operatingSystem=$env:OperatingSystem; configuration=$env:Configuration };
+ }
+
+ $jobInfoJson = $jobInfo | ConvertTo-Json
+
+ if ($env:HelixApiAccessToken) {
+ $accessTokenParameter="?access_token=$($env:HelixApiAccessToken)"
+ }
+ Write-Host "Job Info: $jobInfoJson"
+ $jobToken = Invoke-RestMethod -Uri "https://helix.dot.net/api/2018-03-14/telemetry/job$($accessTokenParameter)" -Method Post -ContentType "application/json" -Body $jobInfoJson
+ $env:Helix_JobToken = $jobToken
+ Write-Host "##vso[task.setvariable variable=Helix_JobToken;issecret=true;]$env:Helix_JobToken"
+ displayName: Send Windows Job Start Telemetry
+ env:
+ HelixApiAccessToken: $(HelixApiAccessToken)
+ Source: ${{ parameters.helixSource }}
+ Type: ${{ parameters.helixType }}
+ Build: $(Build.BuildNumber)
+ QueueId: $(Agent.Os)
+ Attempt: 1
+ OperatingSystem: $(Agent.Os)
+ Configuration: ${{ parameters.buildConfig }}
+ condition: and(always(), eq(variables['Agent.Os'], 'Windows_NT'))
+- powershell: |
+ $workItemId = Invoke-RestMethod -Uri "https://helix.dot.net/api/2018-03-14/telemetry/job/build?buildUri=$([Net.WebUtility]::UrlEncode($env:BuildUri))" -Method Post -ContentType "application/json" -Body "" `
+ -Headers @{ 'X-Helix-Job-Token'=$env:Helix_JobToken }
+
+ $env:Helix_WorkItemId = $workItemId
+ Write-Host "##vso[task.setvariable variable=Helix_WorkItemId]$env:Helix_WorkItemId"
+ displayName: Send Windows Build Start Telemetry
+ env:
+ BuildUri: $(System.TaskDefinitionsUri)$(System.TeamProject)/_build/index?buildId=$(Build.BuildId)&_a=summary
+ Helix_JobToken: $(Helix_JobToken)
+ condition: and(always(), eq(variables['Agent.Os'], 'Windows_NT'))
+++ /dev/null
-
-parameters:
- agentOs: Windows_NT
- helixSource: 'undefined_defaulted_in_telemetry.yml'
- helixType: 'undefined_defaulted_in_telemetry.yml'
- buildConfig: ''
- steps: []
-
-steps:
-- template: /eng/common/templates/steps/run-on-unix.yml
- parameters:
- agentOs: ${{ parameters.agentOs }}
- steps:
- - task: AzureKeyVault@1
- inputs:
- azureSubscription: 'HelixProd_KeyVault'
- KeyVaultName: HelixProdKV
- SecretsFilter: 'HelixApiAccessToken'
- condition: always()
- - bash: |
- /bin/bash ./telemetry/start-job.sh --source "$Source" --type "$Type" --build "$Build" --queue-id "$QueueId" --attempt "$Attempt" -p "operatingSystem=$OperatingSystem" -p "configuration=$Configuration"
- workingDirectory: $(Build.SourcesDirectory)/eng/common
- displayName: Send Job Start Telemetry
- env:
- HelixApiAccessToken: $(HelixApiAccessToken)
- Source: ${{ parameters.helixSource }}
- Type: ${{ parameters.helixType }}
- Build: $(Build.BuildNumber)
- QueueId: ${{ parameters.agentOs }}
- Attempt: 1
- OperatingSystem: ${{ parameters.agentOs }}
- Configuration: ${{ parameters.buildConfig }}
- condition: always()
- - bash: |
- /bin/bash ./telemetry/build/start.sh --build-uri "$BuildUri"
- workingDirectory: $(Build.SourcesDirectory)/eng/common
- displayName: Send Build Start Telemetry
- env:
- BuildUri: $(System.TaskDefinitionsUri)$(System.TeamProject)/_build/index?buildId=$(Build.BuildId)&_a=summary
- # defined via VSTS variables in start-job.sh
- Helix_JobToken: $(Helix_JobToken)
- condition: always()
-
- - ${{ parameters.steps }}
-
- - bash: |
- /bin/bash ./telemetry/build/end.sh
- workingDirectory: $(Build.SourcesDirectory)/eng/common
- displayName: Send Build End Telemetry
- env:
- # defined via VSTS variables in start-job.sh
- Helix_JobToken: $(Helix_JobToken)
- Helix_WorkItemId: $(Helix_WorkItemId)
- condition: always()
-- template: /eng/common/templates/steps/run-on-windows.yml
- parameters:
- agentOs: ${{ parameters.agentOs }}
- steps:
- - task: AzureKeyVault@1
- inputs:
- azureSubscription: 'HelixProd_KeyVault'
- KeyVaultName: HelixProdKV
- SecretsFilter: 'HelixApiAccessToken'
- condition: always()
- - powershell: |
- ./telemetry/start-job.ps1 -Source $env:Source -Type $env:Type -Build $env:Build -QueueId $env:QueueId -Attempt $env:Attempt -Properties @{ operatingSystem=$env:OperatingSystem; configuration=$env:Configuration } -Verbose
- if ($LASTEXITCODE -ne 0) {
- exit $LASTEXITCODE
- }
- workingDirectory: $(Build.SourcesDirectory)/eng/common
- displayName: Send Job Start Telemetry
- env:
- HelixApiAccessToken: $(HelixApiAccessToken)
- Source: ${{ parameters.helixSource }}
- Type: ${{ parameters.helixType }}
- Build: $(Build.BuildNumber)
- QueueId: ${{ parameters.agentOs }}
- Attempt: 1
- OperatingSystem: ${{ parameters.agentOs }}
- Configuration: ${{ parameters.buildConfig }}
- condition: always()
- - powershell: |
- ./telemetry/build/start.ps1 -BuildUri $env:BuildUri
- if ($LASTEXITCODE -ne 0) {
- exit $LASTEXITCODE
- }
- workingDirectory: $(Build.SourcesDirectory)/eng/common
- displayName: Send Build Start Telemetry
- env:
- BuildUri: $(System.TaskDefinitionsUri)$(System.TeamProject)/_build/index?buildId=$(Build.BuildId)&_a=summary
- # defined via VSTS variables in start-job.ps1
- Helix_JobToken: $(Helix_JobToken)
- condition: always()
-
- - ${{ parameters.steps }}
-
- - powershell: |
- ./telemetry/build/end.ps1
- if ($LASTEXITCODE -ne 0) {
- exit $LASTEXITCODE
- }
- workingDirectory: $(Build.SourcesDirectory)/eng/common
- displayName: Send Build End Telemetry
- env:
- # defined via VSTS variables in start-job.ps1
- Helix_JobToken: $(Helix_JobToken)
- Helix_WorkItemId: $(Helix_WorkItemId)
- condition: always()