onnxruntime/tools/ci_build/github/azure-pipelines/templates/telemetry-steps.yml
Changming Sun a8ad0edbeb
BUG FIX: the if...else in telemetry-steps.yml does not really work (#14972)
### Description
BUG FIX: the if...else in telemetry-steps.yml does not really work. It
always says "Telemetry is disabled." even through the pipeline doesn't
have the pipeline variable.

### Motivation and Context
For example, recently I setup a new pipeline in
https://dev.azure.com/onnxruntime/onnxruntime/_build without setting the
ADO variable, but the powershell code still thinks that we have enabled
telemetry.

See:

https://dev.azure.com/onnxruntime/onnxruntime/_build/results?buildId=910107&view=results

The reason it didn't work because when the pipeline
variable("TELEMETRYGUID") doesn't exist,  the occurrence of
 "$(TELEMETRYGUID)" would be not replace to anything. It will remain as
it is.
2023-03-10 15:39:07 -08:00

19 lines
No EOL
887 B
YAML

# sets the TelemetryOption variable and optionally generates TraceLoggingConfigPrivate.h based on the TELEMETRYGUID
# variable
steps:
# TELEMETRYGUID is a runtime variable that is stored on the pipeline in an old-fashioned way. So it cannot be used in
# template expressions. We access it through env variables.
- task: PowerShell@2
displayName: 'Set TelemetryOption variable and optionally create TraceLoggingConfigPrivate.h for WinML Telemetry'
inputs:
targetType: filePath
filePath: $(Build.SourcesDirectory)\tools\ci_build\github\windows\set_telemetry_var.ps1
failOnStderr: true
showWarnings: true
workingDirectory: $(Build.SourcesDirectory)
env:
# When the pipeline variable does not exist, the following line will create a new env variable with value of
# what you see here.
TELEMETRYGUID: $(TELEMETRYGUID)