Permalink
Find file
361 lines (350 sloc) 13.8 KB

Logging Commands:

The general format for a logging command is:

##vso[area.action property1=value;property2=value;...]message

To invoke a logging command, simply emit the command via standard output. For example, from a PowerShell task:

Write-Host "##vso[task.setvariable variable=testvar;]testvalue"

Task Logging Commands:

Syntax Property Name Usage Minimum Agent Version

##vso[task.logissue]error/warning message

type=error or warning (Required)
sourcepath=source file location
linenumber=line number
columnnumber=column number
code=error or warning code

Log error or warning issue to timeline record of current task.
Example:
##vso[task.logissue type=error;sourcepath=consoleapp/main.cs;linenumber=1;columnnumber=1;code=100;]this is an error

##vso[task.setprogress]current operation

value=percentage of completion

Set progress and current operation for current task.
Example:
##vso[task.setprogress value=75;]Upload Log

##vso[task.complete]current operation

result=Succeeded|SucceededWithIssues|Failed|Cancelled|Skipped

Finish timeline record for current task, set task result and current operation. When result not provide, set result to succeeded.
Example:
##vso[task.complete result=Succeeded;]DONE

1.95

##vso[task.logdetail]current operation

id=Timeline record Guid (Required)
parentid=Parent timeline record Guid
type=Record type (Required for first time, can't overwrite)
name=Record name (Required for first time, can't overwrite)
order=order of timeline record (Required for first time, can't overwrite)
starttime=Datetime
finishtime=Datetime
progress=percentage of completion
state=Unknown|Initialized|InProgress|Completed
result=Succeeded|SucceededWithIssues|Failed|Cancelled|Skipped

Create and update detail timeline records.
The first time we saw ##vso[task.detail] for each task, we will create a detail timeline for the task.
We will create and update nested timeline record base on id and parentid.
Task author need to remember which Guid they used for each timeline record. The logging system will keep tracking the Guid for each timeline records that been created, so any new Guid will result a new timeline record.
Examples:
Create new root timeline record: ##vso[task.logdetail id=new guid;name=project1;type=build;order=1]create new timeline record
Create new nested timeline record: ##vso[task.logdetail id=new guid;parentid=exist timeline record guid;name=project1;type=build;order=1]create new nested timeline record
Update exist timeline record: ##vso[task.logdetail id=exist timeline record guid;progress=15;state=InProgress;]update timeline record

##vso[task.setvariable]value

variable=variable name (Required)

issecret=true (Optional)

Sets a variable in the variable service of taskcontext. The first task can set a variable, and following tasks are able to use the variable. The variable is exposed to the following tasks as an environment variable. When issecret is set to true, the value of the variable will be saved as secret and masked out from log. Secret variables are not passed into tasks as environment variables and must be passed as inputs.
Examples:
##vso[task.setvariable variable=testvar;]testvalue
##vso[task.setvariable variable=testvar;issecret=true;]testvalue

##vso[task.addattachment]value

type=attachment type (Required)
name=attachment name (Required)

Upload and attach attachment to current timeline record. These files are not available for download with logs. These can only be referred to by extensions using the type or name values.
Example:
##vso[task.addattachment type=myattachmenttype;name=myattachmentname;]c:\myattachment.txt

##vso[task.uploadsummary]local file path

Upload and attach summary markdown to current timeline record. This summary shall be added to the build/release summary and not available for download with logs.
Examples:
##vso[task.uploadsummary]c:\testsummary.md
It is a short hand form for the command
##vso[task.addattachment type=Distributedtask.Core.Summary;name=testsummaryname;]c:\testsummary.md

0.5.6

##vso[task.uploadfile]local file path

Upload user interested file as additional log information to the current timeline record. The file shall be available for download along with task logs.
Example:
##vso[task.uploadfile]c:\additionalfile.log

1.101

Artifact Logging Commands:

Syntax Property Name Usage Minimum Agent Version

##vso[artifact.associate]artifact location

artifactname=artifact name (Required)
type=container|filepath|versioncontrol|gitref|tfvclabel, artifact type (Required)

Create an artifact link, artifact location is required to be a file container path, VC path or UNC share path.
Examples:
##vso[artifact.associate type=container;artifactname=MyServerDrop]#/1/build
##vso[artifact.associate type=filepath;artifactname=MyFileShareDrop]\\MyShare\MyDropLocation
##vso[artifact.associate type=versioncontrol;artifactname=MyTfvcPath]$/MyTeamProj/MyFolder
##vso[artifact.associate type=gitref;artifactname=MyTag]refs/tags/MyGitTag
##vso[artifact.associate type=tfvclabel;artifactname=MyTag]MyTfvcLabel

##vso[artifact.upload]local file path

containerfolder=folder that the file will upload to, folder will be created if needed. (Required)
artifactname=artifact name

Upload local file into a file container folder, create artifact if artifactname provided.
Example:
##vso[artifact.upload containerfolder=testresult;artifactname=uploadedresult;]c:\testresult.trx

Build Logging Commands:

Syntax Property Name Usage Minimum Agent Version

##vso[build.uploadlog]local file path

Upload user interested log to build’s container “logs\tool” folder.
Example:
##vso[build.uploadlog]c:\msbuild.log

##vso[build.updatebuildnumber]build number

Update build number for current build.
Example:
##vso[build.updatebuildnumber]my-new-build-number

1.88

##vso[build.addbuildtag]build tag

Add a tag for current build.
Example:
##vso[build.addbuildtag]Tag_UnitTestPassed

1.95