Skip to content

Commit 58ac83a

Browse files
authored
Fixed example with output variable
1 parent d7f9fc7 commit 58ac83a

File tree

1 file changed

+28
-19
lines changed

1 file changed

+28
-19
lines changed

docs/pipelines/scripts/logging-commands.md

Lines changed: 28 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -268,38 +268,46 @@ See [set variables in scripts](https://docs.microsoft.com/azure/devops/pipelines
268268

269269
Set the variables:
270270

271-
```bash
272-
echo "##vso[task.setvariable variable=sauce;]crushed tomatoes"
273-
echo "##vso[task.setvariable variable=secretSauce;issecret=true]crushed tomatoes with garlic"
274-
echo "##vso[task.setvariable variable=outputSauce;isoutput=true]canned goods"
271+
```yaml
272+
- bash: |
273+
echo "##vso[task.setvariable variable=sauce;]crushed tomatoes"
274+
echo "##vso[task.setvariable variable=secretSauce;issecret=true]crushed tomatoes with garlic"
275+
echo "##vso[task.setvariable variable=outputSauce;isoutput=true]canned goods"
276+
name: SetVars
275277
```
276278
277279
Read the variables:
278280
279-
```bash
280-
echo "Non-secrets automatically mapped in, sauce is $SAUCE"
281-
echo "Secrets are not automatically mapped in, secretSauce is $SECRETSAUCE"
282-
echo "You can use macro replacement to get secrets, and they'll be masked in the log: $(secretSauce)"
283-
echo "Future jobs can also see $(jobName.stepName.outputSauce)"
281+
```yaml
282+
- bash: |
283+
echo "Non-secrets automatically mapped in, sauce is $SAUCE"
284+
echo "Secrets are not automatically mapped in, secretSauce is $SECRETSAUCE"
285+
echo "You can use macro replacement to get secrets, and they'll be masked in the log: $(secretSauce)"
286+
echo "Future jobs can also see $SETVARS_OUTPUTSAUCE"
287+
echo "Future jobs can also see $(SetVars.outputSauce)"
284288
```
285289
286290
# [PowerShell](#tab/powershell)
287291
288292
Set the variables:
289293
290-
```ps
291-
Write-Host "##vso[task.setvariable variable=sauce;]crushed tomatoes"
292-
Write-Host "##vso[task.setvariable variable=secretSauce;issecret=true]crushed tomatoes with garlic"
293-
Write-Host "##vso[task.setvariable variable=outputSauce;isoutput=true]canned goods"
294+
```yaml
295+
- pwsh: |
296+
Write-Host "##vso[task.setvariable variable=sauce;]crushed tomatoes"
297+
Write-Host "##vso[task.setvariable variable=secretSauce;issecret=true]crushed tomatoes with garlic"
298+
Write-Host "##vso[task.setvariable variable=outputSauce;isoutput=true]canned goods"
299+
name: SetVars
294300
```
295301
296302
Read the variables:
297303
298-
```ps
299-
Write-Host "Non-secrets automatically mapped in, sauce is $env:SAUCE"
300-
Write-Host "Secrets are not automatically mapped in, secretSauce is $env:SECRETSAUCE"
301-
Write-Host "You can use macro replacement to get secrets, and they'll be masked in the log: $(secretSauce)"
302-
Write-Host "Future jobs can also see $env:OUTPUTSAUCE"
304+
```yaml
305+
- pwsh: |
306+
Write-Host "Non-secrets automatically mapped in, sauce is $env:SAUCE"
307+
Write-Host "Secrets are not automatically mapped in, secretSauce is $env:SECRETSAUCE"
308+
Write-Host "You can use macro replacement to get secrets, and they'll be masked in the log: $(secretSauce)"
309+
Write-Host "Future jobs can also see $env:SETVARS_OUTPUTSAUCE"
310+
write-Host "Future jobs can also see $(SetVars.outputSauce)"
303311
```
304312
305313
---
@@ -308,9 +316,10 @@ Console output:
308316
309317
```
310318
Non-secrets automatically mapped in, sauce is crushed tomatoes
311-
Secrets are not automatically mapped in, secretSauce is
319+
Secrets are not automatically mapped in, secretSauce is
312320
You can use macro replacement to get secrets, and they'll be masked in the log: ***
313321
Future jobs can also see canned goods
322+
Future jobs can also see canned goods
314323
```
315324

316325
### SetEndpoint: Modify a service connection field

0 commit comments

Comments
 (0)