Skip to content

Commit 95d3507

Browse files
authored
Merge pull request #92 from microsoft/copilot/suppress-ado-auth-logs
Suppress auth-ado log output by default, add ARTIFACTS_HELPER_VERBOSE
2 parents 122bd2e + b2529a1 commit 95d3507

File tree

3 files changed

+35
-7
lines changed

3 files changed

+35
-7
lines changed

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": {
Lines changed: 22 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,22 +30,25 @@ 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"
36+
# Return 0 to indicate successful authentication
2237
return 0
2338
fi
2439
sleep 2
2540
ELAPSED=$((ELAPSED + 2))
2641

2742
# Progress indicator every 20 seconds
2843
if [ $((ELAPSED % 20)) -eq 0 ]; then
29-
echo " Still waiting... (${ELAPSED}s elapsed)"
44+
log_message " Still waiting... (${ELAPSED}s elapsed)"
3045
fi
3146
done
3247

3348
# Timeout reached - continue without authentication
49+
# Always show timeout warnings regardless of verbose setting, as this indicates a potential issue
3450
echo "::warning::AzDO Authentication Helper not found after ${MAX_WAIT} seconds"
3551
echo "Expected location: ${HOME}/ado-auth-helper"
3652
echo "Continuing without Azure Artifacts authentication..."
53+
# Return 1 to indicate authentication was not successful, but don't exit (allow sourcing script to continue)
3754
return 1

0 commit comments

Comments
 (0)