Add canonical site URL to deploy JSON output #7737
Closed
Add this suggestion to a batch that can be applied as a single commit. This suggestion is invalid because no changes were made to the code. Suggestions cannot be applied while the pull request is closed. Suggestions cannot be applied while viewing a subset of changes. Only one suggestion per line can be applied in a batch. Add this suggestion to a batch that can be applied as a single commit. Applying suggestions on deleted lines is not supported. You must change the existing code in this line in order to create a valid suggestion. Outdated suggestions cannot be applied. This suggestion has been applied or marked resolved. Suggestions cannot be applied from pending reviews. Suggestions cannot be applied on multi-line comments. Suggestions cannot be applied while the pull request is queued to merge. Suggestion cannot be applied right now. Please check back later.
Problem
The
netlify deploy --jsoncommand inconsistently returned URL information, making it difficult for scripts and automation to reliably access both the canonical site URL and per-deploy URL:deploy_urlurlfield for production deploysSolution
This PR adds a new
site_urlfield that is always present in the JSON output, representing the canonical/primary site URL that remains consistent across all deploys.JSON Output Changes
Before:
{ "deploy_url": "https://abc123--example.netlify.app", "url": "..." // Only present for production deploys }After:
{ "site_url": "https://example.netlify.app", // NEW: Always present "deploy_url": "https://abc123--example.netlify.app", // Always present "url": "https://example.netlify.app" // Production only (backward compat) }Changes
site_urlfield toJsonDatainterface - The canonical/primary site URL (e.g.,https://example.netlify.app) that remains consistent across deploysprintResultsfunction - Now includessite_urlin all JSON outputs, regardless of deployment typesite_urlpresenceField Definitions
site_url: Primary/canonical URL for the site. Remains consistent across deploys. Always present.deploy_url: Unique per-deploy URL. Can be used to preview this specific deploy even after subsequent deploys. Always present.url: (Deprecated) Legacy field, same assite_url. Only present for production deploys for backward compatibility.Benefits
✅ Consistent: Both URLs are now always available in JSON output
✅ Clear: Field names explicitly indicate their purpose
✅ Documented: Comprehensive JSDoc comments explain each field
✅ Backward Compatible: Legacy
urlfield preserved for production deploys✅ Reliable: Scripts can now consistently access the canonical site URL
Breaking Changes
None. This is a backward-compatible enhancement that only adds a new field. The existing
deploy_urlfield and legacyurlfield (for production deploys) remain unchanged.Testing
should include both site_url and deploy_url in JSON outputsite_urlanddeploy_urldiffer for draft deploymentsurlfieldOriginal prompt
💬 We'd love your input! Share your thoughts on Copilot coding agent in our 2 minute survey.