Check Deployment Version Utility
Overview
The check-deployment-version.sh script checks the deployment version of a running environment by querying the frontend and backend API endpoints.
Script Location: cli/sdlc/utils/check-deployment-version.sh
Purpose
This utility helps determine which version of the application is currently deployed by:
- ✅ Checking frontend version API - Queries
/assets/version.jsonfor frontend build info - ✅ Checking backend status API - Attempts to query
/statusfor backend version - ✅ Retrieving commit information - Gets the Git commit SHA of the deployed code
- ✅ Showing build timestamp - Displays when the deployed version was built
- ✅ Providing commit URL - Direct link to the deployed commit on GitHub
- ✅ Environment introspection - Quick way to check what's deployed where
API Endpoints
The script queries these API endpoints:
-
Frontend Version:
https://<environment>.m3.codeproof.app/assets/version.json- Hosted on Firebase (UI domain)
- Public endpoint (no authentication required)
- Returns: Git commit, branch, build timestamp, app version, environment
-
Backend Status:
https://construction-code-expert-esp2-<environment>-<hash>.uc.a.run.app/status- Hosted on Cloud Run ESP2 (Endpoints Service Proxy v2)
- Requires Firebase authentication
- Returns: Backend commit, build info, JVM version, uptime, metadata
Environment URL Mappings
| Environment | UI Base URL | API Base URL (ESP2) |
|---|---|---|
| dev | https://dev.m3.codeproof.app | construction-code-expert-esp2-dev-6yieikr6ca-uc.a.run.app |
| demo | https://demo.m3.codeproof.app | construction-code-expert-esp2-demo-drbpsuscwa-uc.a.run.app |
| test | https://test.m3.codeproof.app | construction-code-expert-esp2-test-fhj3jauezq-uc.a.run.app |
| prod | https://m3.codeproof.app | TBD (prod deployment pending) |
Usage
Basic Syntax
./cli/sdlc/utils/check-deployment-version.sh <environment> [--auth <user-email>]
Parameters:
environment- Environment name:dev,demo,test, orprod--auth <user-email>- (Optional) Authenticate to fetch backend status information
Examples
Check Dev Environment (Frontend Only)
./cli/sdlc/utils/check-deployment-version.sh dev
Output (frontend version only, no authentication):
🔍 Checking deployment version
🌐 Environment: dev
📡 Frontend API: https://dev.m3.codeproof.app/assets/version.json
📡 Backend API: https://construction-code-expert-esp2-dev-6yieikr6ca-uc.a.run.app/status (requires auth)
Checking frontend version...
✅ Frontend version API is available
📊 Frontend Version Information:
Git Commit: bb43ec600a0675bfe98d5ec2671c853d0fc14eb0
Commit URL: https://github.com/sanchos101/construction-code-expert/commit/bb43ec600a0675bfe98d5ec2671c853d0fc14eb0
Build Timestamp: 2025-09-23T01:26:51.000Z
App Version: 1.0.0
Git Branch: main
Environment: dev
📄 Full Frontend Response:
{
"version": "1.0.0",
"gitCommit": "bb43ec600a0675bfe98d5ec2671c853d0fc14eb0",
"gitBranch": "main",
"buildTimestamp": "2025-09-23T01:26:51.000Z",
"environment": "dev",
"nodeEnv": "production"
}
Checking backend status...
⚠️ Backend status API requires authentication (401)
💡 The /status endpoint requires Firebase authentication
💡 Use the frontend version.json info above for deployment verification
✅ Check complete!
Check Demo Environment
./cli/sdlc/utils/check-deployment-version.sh demo
Output (when version API is not available):
🔍 Checking deployment version
🌐 Environment: demo
📡 Frontend API: https://demo.m3.codeproof.app/assets/version.json
📡 Backend API: https://construction-code-expert-esp2-demo-drbpsuscwa-uc.a.run.app/status (requires auth)
Checking frontend version...
⚠️ Frontend version API not found (404)
💡 This is expected for older deployments without the version.json file
ℹ️ To determine the deployment version, use:
./cli/sdlc/utils/get-cloudrun-image.sh demo
✅ Check complete!
Check Test Environment with Backend Info
./cli/sdlc/utils/check-deployment-version.sh test --auth ai-swe-agent-test@codetricks.org
Output (with backend authentication):
🔍 Checking deployment version
🌐 Environment: test
📡 Frontend API: https://test.m3.codeproof.app/assets/version.json
📡 Backend API: https://construction-code-expert-esp2-test-fhj3jauezq-uc.a.run.app/status (requires auth)
Checking frontend version...
✅ Frontend version API is available
📊 Frontend Version Information:
Git Commit: 2237ca07295d6298d659637299c134c90740e6ca
Commit URL: https://github.com/sanchos101/construction-code-expert/commit/2237ca07295d6298d659637299c134c90740e6ca
Build Timestamp: 2025-11-07T05:11:47.365Z
App Version: 0.0.0
Git Branch: feature/issue-291-image-object-search
Environment: test
📄 Full Frontend Response:
{
"version": "0.0.0",
"gitCommit": "2237ca07295d6298d659637299c134c90740e6ca",
"gitBranch": "feature/issue-291-image-object-search",
"buildTimestamp": "2025-11-07T05:11:47.365Z",
"environment": "test",
"nodeEnv": "development"
}
Checking backend status...
🔐 Authenticating as: ai-swe-agent-test@codetricks.org
Generating Firebase token...
✅ Firebase token generated
✅ Backend status API authenticated successfully
📊 Backend Status Information:
Backend Git Commit: 1cc4057e2f802c710ab27343688fb583a3addbfa
Commit URL: https://github.com/sanchos101/construction-code-expert/commit/1cc4057e2f802c710ab27343688fb583a3addbfa
Git Branch: feature/issue-291-image-object-search
Build Timestamp: 2025-11-06T21:54:48-0800
App Version: 1.0-SNAPSHOT
JVM Version: 23.0.2
Uptime: 0h 0m (582 ms)
Container Image: us-central1-docker.pkg.dev/.../construction-code-expert-grpc:1cc4057
📄 Full Backend Response:
{
"commitHash": "1cc4057e2f802c710ab27343688fb583a3addbfa",
"gitBranch": "feature/issue-291-image-object-search",
"buildTimestamp": "2025-11-06T21:54:48-0800",
"appVersion": "1.0-SNAPSHOT",
"jvmVersion": "23.0.2",
"uptimeMs": "582",
"containerImage": "us-central1-docker.pkg.dev/.../construction-code-expert-grpc:1cc4057",
"metadata": { ... }
}
✅ Check complete!
Check Production Environment
./cli/sdlc/utils/check-deployment-version.sh prod
Output Explanation
Successful Response (200)
When the frontend version API exists and returns successfully:
- Git Commit - The Git commit hash of the deployed frontend code
- Commit URL - Direct GitHub link to view the commit details
- Build Timestamp - When the deployed build was created
- App Version - Application version from package.json
- Git Branch - The branch the build was created from
- Environment - Target environment (dev, demo, test, prod)
- Full Response - Complete JSON response from the endpoint
Backend Status
The script can check the backend /status endpoint when the --auth flag is provided:
Without --auth flag:
- 401/403 - Normal behavior, backend requires Firebase authentication
- Script suggests using
--auth <user-email>to get backend info
With --auth flag:
- Generates Firebase ID token using
firebase-token-generator/generate-token.sh - Makes authenticated request to
/statusendpoint - Returns backend deployment information:
- Backend Git commit and branch
- Build timestamp
- JVM version
- Server uptime
- Container image URI
- Additional metadata (Cloud Run details, memory usage, etc.)
Not Found (404)
When the frontend version API doesn't exist:
- Indicates an older deployment that predates the version.json file feature
- Suggests using
get-cloudrun-image.shas an alternative
Connection Error
When the service is unreachable:
- Network connectivity issues
- Service not deployed
- Incorrect URL
Use Cases
1. Pre-Deployment Verification
Before deploying to an environment, check what's currently running:
# Check current frontend and backend versions in dev (with authentication)
./cli/sdlc/utils/check-deployment-version.sh dev --auth sanchos101@gmail.com
# Compare with latest commit
git log -1 --oneline
2. Environment Comparison
Compare versions across environments:
echo "=== Dev Environment ==="
./cli/sdlc/utils/check-deployment-version.sh dev --auth sanchos101@gmail.com
echo ""
echo "=== Test Environment ==="
./cli/sdlc/utils/check-deployment-version.sh test --auth ai-swe-agent-test@codetricks.org
echo ""
echo "=== Demo Environment ==="
./cli/sdlc/utils/check-deployment-version.sh demo --auth sanchos101@gmail.com
3. Deployment Validation
After deploying, verify the new version is live:
# Deploy to dev
./cli/sdlc/full-stack-deploy.sh dev
# Wait for deployment to complete
sleep 60
# Verify deployed version (both frontend and backend)
./cli/sdlc/utils/check-deployment-version.sh dev --auth sanchos101@gmail.com
# Check that backend commit matches what we just deployed
EXPECTED_COMMIT=$(git rev-parse HEAD)
echo "Expected commit: $EXPECTED_COMMIT"
4. Incident Investigation
During an incident, quickly identify what's deployed:
# Check production version
./cli/sdlc/utils/check-deployment-version.sh prod
# Check if it matches the expected release
echo "Expected commit: v2.5.3"
5. Release Notes Preparation
Determine the delta between environments for release planning:
#!/bin/bash
# compare-environments.sh
DEV_COMMIT=$(./cli/sdlc/utils/check-deployment-version.sh dev 2>/dev/null | grep "Commit SHA:" | awk '{print $3}')
PROD_COMMIT=$(./cli/sdlc/utils/check-deployment-version.sh prod 2>/dev/null | grep "Commit SHA:" | awk '{print $3}')
echo "Changes from prod to dev:"
git log --oneline $PROD_COMMIT..$DEV_COMMIT
Prerequisites
- curl - HTTP client (usually pre-installed)
- jq - JSON processor (optional, for better formatting)
- Network access - To the target environment's URL
- firebase-token-generator - (For
--authflag) Node.js token generator - gcloud CLI - (For
--authflag) Required by firebase-token-generator
Installation
# Install jq for better output formatting (optional)
brew install jq # macOS
sudo apt-get install jq # Ubuntu/Debian
Environment URLs
The script automatically maps environments to URLs:
| Environment | UI URL | API URL (ESP2) | Project ID |
|---|---|---|---|
| dev | https://dev.m3.codeproof.app | construction-code-expert-esp2-dev-6yieikr6ca-uc.a.run.app | construction-code-expert-dev |
| demo | https://demo.m3.codeproof.app | construction-code-expert-esp2-demo-drbpsuscwa-uc.a.run.app | construction-code-expert-demo |
| test | https://test.m3.codeproof.app | construction-code-expert-esp2-test-fhj3jauezq-uc.a.run.app | construction-code-expert-test |
| prod | https://m3.codeproof.app | TBD | construction-code-expert-prod |
Note: The UI is hosted on Firebase (m3.codeproof.app), while the API is hosted on Cloud Run using ESP2 (Endpoints Service Proxy v2).
Integration with Other Tools
With get-cloudrun-image.sh
When /version endpoint is not available, use the Cloud Run image utility:
# Try version endpoint first
./cli/sdlc/utils/check-deployment-version.sh demo
# If 404, use Cloud Run image check
./cli/sdlc/utils/get-cloudrun-image.sh demo
With Git Commands
Compare deployed version with current branch:
DEPLOYED_COMMIT=$(./cli/sdlc/utils/check-deployment-version.sh dev | grep "Commit SHA:" | awk '{print $3}')
CURRENT_COMMIT=$(git rev-parse HEAD)
if [ "$DEPLOYED_COMMIT" == "$CURRENT_COMMIT" ]; then
echo "✅ Dev is up to date"
else
echo "⚠️ Dev is behind by $(git rev-list --count $DEPLOYED_COMMIT..$CURRENT_COMMIT) commits"
fi
In CI/CD Pipelines
Verify deployment in automated workflows:
# .github/workflows/deploy.yml
- name: Verify deployment
run: |
DEPLOYED_VERSION=$(./cli/sdlc/utils/check-deployment-version.sh dev | grep "Commit SHA:" | awk '{print $3}')
if [ "$DEPLOYED_VERSION" != "$GITHUB_SHA" ]; then
echo "❌ Deployment verification failed"
exit 1
fi
echo "✅ Deployment verified"
API Endpoint Details
Frontend Version API
Endpoint: /assets/version.json
Type: Static JSON file generated at build time
Authentication: None (public)
Response Format:
{
"version": "string", // App version from package.json
"gitCommit": "string", // Git commit SHA
"gitBranch": "string", // Git branch name
"buildTimestamp": "string", // Build time (ISO 8601 format)
"environment": "string", // Target environment (dev, demo, test, prod)
"nodeEnv": "string" // Node environment (production, development)
}
Implementation: Generated by web-ng-m3/scripts/generate-version.js during Angular build
Note: Older deployments (before September 2025) may not have this file.
Backend Status API
Endpoint: /status
Type: gRPC REST endpoint (StatusService.GetStatus)
Authentication: Firebase ID Token required
Response Format:
{
"commitHash": "string", // Git commit SHA
"gitBranch": "string", // Git branch name
"buildTimestamp": "string", // Build time (ISO 8601 format)
"appVersion": "string", // App version from Maven
"jvmVersion": "string", // Java version
"uptimeMs": number, // Server uptime in milliseconds
"containerImage": "string", // Docker image URI
"metadata": { // Additional metadata
"cloudrun.service": "string",
"cloudrun.revision": "string",
// ... more metadata
}
}
Implementation: src/main/java/org/codetricks/construction/code/assistant/service/StatusServiceImpl.java
Note: Requires Firebase authentication, so the script typically shows a 401 response for this endpoint.
Troubleshooting
jq Not Installed
If jq is not installed, the script falls back to displaying raw JSON:
⚠️ jq not installed, showing raw response
💡 Install jq for better formatting: sudo apt-get install jq
{"frontEndCommit":"abc123...","buildTimestamp":"9/23/2025, 1:26:51 AM"}
Solution: Install jq for better output formatting (optional).
Connection Timeout
❌ Failed to connect to https://demo.codeproof.app/version
💡 Possible causes:
- Network connectivity issue
- Service is not deployed
- URL is incorrect
Possible Causes:
- Network connectivity problems
- VPN required but not connected
- Service is down or not deployed
- Firewall blocking the request
Solution: Check network connectivity and service status.
HTTP 404 - Not Found
⚠️ /version endpoint not found (404)
💡 This is expected for older deployments without the /version endpoint
This is normal for deployments created before the /version endpoint was added.
Alternative: Use get-cloudrun-image.sh to determine deployment details via Cloud Run metadata.
Best Practices
1. Check Before Deployment
Always check the current version before deploying:
# Pre-deployment check
./cli/sdlc/utils/check-deployment-version.sh dev
2. Document Deployment Versions
Keep track of what's deployed where:
# Save deployment state
echo "$(date): Dev deployment" >> deployment-log.txt
./cli/sdlc/utils/check-deployment-version.sh dev >> deployment-log.txt
3. Automate Version Checks
Create scripts that check all environments:
#!/bin/bash
# check-all-environments.sh
for env in dev test demo prod; do
echo "=== $env ==="
./cli/sdlc/utils/check-deployment-version.sh $env
echo ""
done
4. Compare with Git Tags
Match deployed commits with release tags:
DEPLOYED=$(./cli/sdlc/utils/check-deployment-version.sh prod | grep "Commit SHA:" | awk '{print $3}')
git tag --contains $DEPLOYED
See Also
- Get Cloud Run Image Utility - Alternative method using Cloud Run metadata
- Developer Playbook
- Release Management
- Environment Provisioning