scripts/setup_ado_credentials.sh¶
Platforms: macOS.
Purpose¶
setup_ado_credentials.sh prompts for an Azure DevOps Personal Access Token
(PAT) and stores it with git credential approve for https://dev.azure.com,
so subsequent git push/pull against an Azure DevOps remote authenticate
without further prompts. It assumes a git remote named ado already points
at the target dev.azure.com repository.
Requirements¶
gitonPATH.- An Azure DevOps organization and a PAT with at least Code (Read &
Write) scope, generated at
https://dev.azure.com/<YourOrg>/_usersSettings/tokens. - Keychain storage only actually happens if Git's credential helper is
configured as
osxkeychain. The script pipes the credential togit credential approve, which hands it to whatevercredential.helperis configured —osxkeychainis common on macOS but not guaranteed to be the active helper. If a different (or no) helper is configured, the PAT is stored wherever that helper stores it, not necessarily the macOS Keychain. - A local
adogit remote for the verification step (git ls-remote ado HEAD) to succeed.
Usage¶
The script takes no arguments; it prompts interactively for the PAT
(read -rsp, not echoed to the terminal).
Effects¶
- Prompts for the PAT without echoing it to the terminal.
- Exits
1immediately if the input is empty. - Pipes a credential record (
protocol=https,host=dev.azure.com, a placeholderusername, and the PAT aspassword) togit credential approve, which stores it via the configuredcredential.helper. - Runs
git ls-remote ado HEADto verify the stored credential actually authenticates against theadoremote.
Exit behavior¶
0— the PAT was stored viagit credential approve, regardless of whether the verification step in effect 4 succeeded. A failed verification only prints a warning; it does not change the exit code.1— no PAT was entered at the prompt.- Any other non-zero exit comes from
set -euo pipefailsurfacing a failure ingit credential approveitself (for example, no credential helper configured at all).
Common failures¶
Could not verify accesswarning after a seemingly successful store — expected when the PAT lacksCode (Read & Write)scope, or whencredential.helperisn't set to a helper this shell session can read back from; trygit push ado <branch>directly to see the underlying error.- PAT stored but git still prompts on push — check
git config --get credential.helper; if it's unset or notosxkeychain, the credential was stored by a different mechanism (or not persisted at all) and the Keychain won't have it. adoremote not found — add it first withgit remote add ado https://dev.azure.com/<org>/<project>/_git/<repo>.
Related commands¶
- Script reference — Setup
setup.sh— the main setup entry point this is unrelated to functionally; both live under Setup because they are one-shot machine-bootstrap scripts.