NOTE: If you are looking for the new Azure DevOps CLI, see vsts-cli
This is a command-line utility for interacting with Microsoft Team Foundation Server and Azure DevOps Services (formerly VSTS). It is cross platform and supported on Windows, MacOS, and Linux.
Setup
First, download and install Node.js 4.0.x or later and npm (included with the installer)
tfx extension (extensions): Package, manage, publish Team Foundation Server / Azure DevOps extensions.
tfx workitem (work items): Create, query and view work items.
Login
To avoid providing credentials with every command, you can login once. Currently supported credential types: Personal Access Tokens and basic authentication credentials.
NTLM support is under consideration
Warning! Using this feature will store your login credentials on disk in plain text.
To skip certificate validation connecting to on-prem Azure DevOps Server use the --skip-cert-validation parameter.
You can also use basic authentication by passing the --auth-type basic parameter (see Configuring Basic Auth for details).
Settings cache
To avoid providing options with every command, you can save them to a settings file by adding the --save flag.
~$ tfx build list --project MyProject --definition-name println --top 5 --save...id : 1definition name : TestDefinitionrequested by : Teddy Wardstatus : NotStartedqueue time : Fri Aug 21 2015 15:07:49 GMT-0400 (Eastern Daylight Time)~$ tfx build listCopyright Microsoft Corporation...id : 1definition name : TestDefinitionrequested by : Teddy Wardstatus : NotStartedqueue time : Fri Aug 21 2015 15:07:49 GMT-0400 (Eastern Daylight Time)
If you used --save to set a default value for an option, you may need to override it by explicitly providing a different value. You can clear any saved settings by running tfx reset.
Troubleshooting & Verbose Logging
CLI Trace Output
To see detailed tracing output from the CLI, set the TFX_TRACE environment variable and then run commands. This may provide clues to the issue and can be helpful when logging an issue.
Linux/OSX:
export TFX_TRACE=1
Windows:
set TFX_TRACE=1
PowerShell:
$env:TFX_TRACE=1
Debug Output from Tests
To enable detailed debug output for all CLI commands executed during tests, set the DEBUG_CLI_OUTPUT environment variable to true:
Linux/OSX:
export DEBUG_CLI_OUTPUT=true
Windows:
set DEBUG_CLI_OUTPUT=true
PowerShell:
$env:DEBUG_CLI_OUTPUT='true'
This will print detailed command execution logs for every CLI call made by the test suite.
Mock Server Verbose Logging
To enable verbose logging for the integrated mock server (used in server integration tests), set the DEBUG_MOCKSERVER_OUTPUT environment variable to true:
Linux/OSX:
export DEBUG_MOCKSERVER_OUTPUT=true
Windows:
set DEBUG_MOCKSERVER_OUTPUT=true
PowerShell:
$env:DEBUG_MOCKSERVER_OUTPUT='true'
This will print detailed request/response and lifecycle logs from the mock server during test runs.
All three variables (TFX_TRACE, DEBUG_CLI_OUTPUT, DEBUG_MOCKSERVER_OUTPUT) are also available as pipeline variables in the Azure DevOps pipeline and default to false.
Development
Building from Source
To build the project from source:
Install dependencies:
npm install
Build the main project:
npm run build
This compiles the TypeScript source files in the app/ directory to JavaScript in the _build/ directory using the TypeScript compiler and copies necessary files.
Clean build artifacts (optional):
npm run clean
Testing
The project includes comprehensive tests, including server integration tests with an integrated mock server. To run them:
Build the project first (required):
npm run build
Run all tests:
npm test
This builds the test files and runs all test suites.
Run specific test suites:
npm run test:build-commandsnpm run test:extension-commandsnpm run test:commandlinenpm run test:server-integration
Run tests with CI reporter:
npm run test:ci
Note: The mock server is now integrated as part of the test suite in the tests/mock-server/ directory and is automatically compiled when running tests. No separate build step is required for the mock server.
Enabling Mock Server Verbose Logging
For debugging server integration tests, you can enable verbose logging for the mock server to see detailed request/response information. This requires modifying the test files temporarily:
Locate the test file you want to debug (e.g., tests/server-integration-login.ts)
Find the createMockServer call in the before() hook:
Authorization headers (with tokens obscured for security)
Mock server lifecycle events
Request processing details
Example verbose output:
Mock DevOps server listening on http://localhost:8084Mock Server: GET /_apis/connectionData - Authorization: Basic tes***assMock Server: POST /_apis/build/builds - Authorization: Bearer abc***xyzMock DevOps server closed
Important: Remember to remove the verbose: true option before committing your changes, as it's intended for debugging purposes only.
Testing Your Changes Locally
After building, you can test your changes locally in several ways: