devops_utils.core.envfile module
Load Azure DevOps settings from an env file into os.environ.
AzureDevOpsClient.from_env reads only process environment variables. On
Windows that means setx/$env: juggling, and an MCP server launched by
Claude Desktop or Claude Code never sees variables set in a PowerShell session.
An env file next to the user’s profile works the same on every OS and every
launcher.
Only the first existing file of these is used:
$DEVOPS_UTILS_ENV_FILE— an explicit path../.env.devops-utils— project scope (keep it out of git).~/.devops-utils.env— user scope (%USERPROFILE%on Windows).
Files are never merged, and a variable already in the process environment
always wins. Both rules exist so a cloned repo’s project file cannot pair its
own AZURE_DEVOPS_ORG_URL with the token from your user file or session and
ship that token to a server of its choosing. For the same reason an org URL
from a file is ignored unless the token in effect comes from that same file,
and only AZURE_DEVOPS_* keys are ever loaded.
The format is the usual KEY=VALUE subset: # comments, blank lines, an
optional leading export, and optional matching single/double quotes. A UTF-8
BOM and CRLF line endings — what Notepad writes — are tolerated. Nothing is
expanded or executed.
- devops_utils.core.envfile.ENV_FILE_VAR = 'DEVOPS_UTILS_ENV_FILE'
Env var naming an explicit env file to load first.
- devops_utils.core.envfile.KEY_PREFIX = 'AZURE_DEVOPS_'
Only keys with this prefix are loaded from a file.
- devops_utils.core.envfile.PROJECT_ENV_FILE = '.env.devops-utils'
Project-scope env file name (resolved against the current directory).
- devops_utils.core.envfile.USER_ENV_FILE = '.devops-utils.env'
User-scope env file name (resolved against the home directory).
- devops_utils.core.envfile.env_file_candidates() list[Path][source]
Return the env files to try, highest precedence first.
- devops_utils.core.envfile.load_env_files(candidates: list[Path] | None = None) Path | None[source]
Fill unset
AZURE_DEVOPS_*variables from the first existing env file.Never overrides a variable that is already set (even to an empty string — an explicit empty value is the user’s choice). Unreadable files are skipped so a stray permission problem can’t stop the CLI from starting.
- Returns:
The file that was used, or
None.