Skip to content

Commit 8944e2f

Browse files
Copilotmarkphip
andcommitted
Suppress auth-ado log output by default, add ARTIFACTS_HELPER_VERBOSE env var
Co-authored-by: markphip <933108+markphip@users.noreply.github.com>
1 parent 0be1631 commit 8944e2f

3 files changed

Lines changed: 33 additions & 7 deletions

File tree

src/artifacts-helper/NOTES.md

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,10 +49,21 @@ This ensures any custom scripting in place during Codespaces build process will
4949
The shim scripts (e.g., `dotnet`, `npm`, `nuget`) now include a wait mechanism for the Azure DevOps authentication helper. When invoked, these scripts will:
5050

5151
1. Wait up to 3 minutes for the `ado-auth-helper` to become available (configurable via `MAX_WAIT` environment variable)
52-
2. Display progress indicators every 20 seconds while waiting
52+
2. Display progress indicators every 20 seconds while waiting (only when `ARTIFACTS_HELPER_VERBOSE=true`)
5353
3. Continue execution once authentication is successful
5454
4. **Continue with the underlying command even if authentication is not available** after the timeout
5555

56+
By default, the authentication process runs silently. To enable verbose logging (useful for troubleshooting), set the `ARTIFACTS_HELPER_VERBOSE` environment variable to `true`:
57+
58+
```bash
59+
export ARTIFACTS_HELPER_VERBOSE=true
60+
```
61+
62+
When verbose mode is enabled, you will see step-by-step messages like:
63+
- `::step::Waiting for AzDO Authentication Helper...`
64+
- `::step::Running ado-auth-helper get-access-token...`
65+
- `::step::✓ Access token retrieved successfully`
66+
5667
This ensures that package restore operations can proceed even if there's a slight delay in the authentication helper installation, which can occur in some codespace initialization scenarios. Commands will still execute without authentication, though they may fail to access private Azure Artifacts feeds.
5768

5869
The scripts are designed to be sourced safely, meaning they won't terminate the calling shell if authentication fails - they will simply return an error code and allow the underlying tool to execute. This allows you to work with public packages or other package sources even when Azure Artifacts authentication is unavailable.

src/artifacts-helper/devcontainer-feature.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"name": "Azure Artifacts Credential Helper",
33
"id": "artifacts-helper",
4-
"version": "3.0.1",
4+
"version": "3.0.2",
55
"description": "Configures Codespace to authenticate with Azure Artifact feeds",
66
"options": {
77
"nugetURIPrefixes": {

src/artifacts-helper/scripts/auth-ado.sh

Lines changed: 20 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,27 @@
11
#!/bin/bash
22

3+
# Helper function to conditionally log messages
4+
# Messages are only shown if ARTIFACTS_HELPER_VERBOSE is set to "true"
5+
log_step() {
6+
if [ "${ARTIFACTS_HELPER_VERBOSE}" = "true" ]; then
7+
echo "::step::$1"
8+
fi
9+
}
10+
11+
log_message() {
12+
if [ "${ARTIFACTS_HELPER_VERBOSE}" = "true" ]; then
13+
echo "$1"
14+
fi
15+
}
16+
317
# If ACTIONS_ID_TOKEN_REQUEST_URL is set, we're in a GitHub Actions environment
418
# Skip Azure DevOps authentication and just execute the real command
519
if [ -n "${ACTIONS_ID_TOKEN_REQUEST_URL}" ]; then
6-
echo "::step::GitHub Actions environment detected, skipping Azure DevOps authentication"
20+
log_step "GitHub Actions environment detected, skipping Azure DevOps authentication"
721
return 0
822
fi
923

10-
echo "::step::Waiting for AzDO Authentication Helper..."
24+
log_step "Waiting for AzDO Authentication Helper..."
1125

1226
# Wait up to 3 minutes for the ado-auth-helper to be installed
1327
# Can be overridden via environment variable for testing
@@ -16,21 +30,22 @@ ELAPSED=0
1630

1731
while [ $ELAPSED -lt $MAX_WAIT ]; do
1832
if [ -f "${HOME}/ado-auth-helper" ]; then
19-
echo "::step::Running ado-auth-helper get-access-token..."
33+
log_step "Running ado-auth-helper get-access-token..."
2034
ARTIFACTS_ACCESSTOKEN=$(${HOME}/ado-auth-helper get-access-token)
21-
echo "::step::✓ Access token retrieved successfully"
35+
log_step "✓ Access token retrieved successfully"
2236
return 0
2337
fi
2438
sleep 2
2539
ELAPSED=$((ELAPSED + 2))
2640

2741
# Progress indicator every 20 seconds
2842
if [ $((ELAPSED % 20)) -eq 0 ]; then
29-
echo " Still waiting... (${ELAPSED}s elapsed)"
43+
log_message " Still waiting... (${ELAPSED}s elapsed)"
3044
fi
3145
done
3246

3347
# Timeout reached - continue without authentication
48+
# Always show warnings, even if verbose is disabled
3449
echo "::warning::AzDO Authentication Helper not found after ${MAX_WAIT} seconds"
3550
echo "Expected location: ${HOME}/ado-auth-helper"
3651
echo "Continuing without Azure Artifacts authentication..."

0 commit comments

Comments
 (0)