Permalink
Switch branches/tags
Find file Copy path
451 lines (438 sloc) 16.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 a ##vso[task.detail] message is seen for a given task, a detailed timeline is created for that task.
Nested timeline records are created and updated based on id and parentid.
The task author needs to remember which Guid they used for each timeline record. The logging system tracks the Guid for each timeline record that has been created, so any new Guid results in 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=existing 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 in the same phase 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.setendpoint]value

id=endpoint id (Required)

field=field type authParameter|dataParameter|url (Required)

key=key (Required. Except for field=url)

value=value for key or url(Required)

Set an endpoint field with given value. Value updated will be retained in the endpoint for the subsequent tasks that execute within the same job.
Examples:
##vso[task.setendpoint id=000-0000-0000;field=authParameter;key=AccessToken]testvalue
##vso[task.setendpoint id=000-0000-0000;field=dataParameter;key=userVariable]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

##vso[task.prependpath]local directory path

Instruction for the agent to update the PATH environment variable. The specified directory is prepended to the PATH. The updated environment variable will be reflected in subsequent tasks.
Example:
##vso[task.prependpath]c:\my\directory\path

2.115.0

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

Release Logging Commands:

Syntax Property Name Usage Minimum Agent Version

##vso[release.updatereleasename]release name

Update release name for current release.
Example:
##vso[release.updatereleasename]my-new-release-name

2.132