Skip to content

Commit d416832

Browse files
committed
fix: add automated port visibility setting and troubleshooting docs
Add gh CLI command to automatically set port 8080 to public during setup. Create .devcontainer/README.md with manual steps for port visibility. The devcontainer.json visibility setting doesn't reliably work, so we now: 1. Attempt automatic setting via gh CLI in setup.sh 2. Provide clear manual steps in README if automation fails This addresses the persistent issue where ports default to private even with visibility: public in devcontainer.json.
1 parent 9f31d77 commit d416832

File tree

2 files changed

+56
-0
lines changed

2 files changed

+56
-0
lines changed

.devcontainer/README.md

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
# Codespaces Configuration
2+
3+
This directory contains the GitHub Codespaces dev container configuration.
4+
5+
## Port Visibility Issue
6+
7+
If port 8080 shows as **private** after creating a Codespace, you need to manually change it to **public**:
8+
9+
### Manual Steps:
10+
1. Open the **PORTS** panel at the bottom of VS Code (next to TERMINAL)
11+
2. Find port **8080** in the list
12+
3. **Right-click** on port 8080
13+
4. Select **Port Visibility****Public**
14+
5. Refresh your browser and access Jenkins
15+
16+
### Why is this needed?
17+
18+
The `devcontainer.json` includes `"visibility": "public"` for port 8080, but GitHub Codespaces may not always apply this setting automatically, especially:
19+
- On the first Codespace creation
20+
- If there's an organization policy
21+
- If the port is forwarded before the container is fully started
22+
23+
The setup script attempts to set the port visibility automatically using the GitHub CLI, but if that fails, manual intervention is required.
24+
25+
## Files
26+
27+
- **devcontainer.json** - Dev container specification
28+
- **setup.sh** - Initialization script (installs yq, configures URLs, creates welcome message)
29+
- **welcome.txt** - Generated welcome message (not in git, created at runtime)
30+
- **README.md** - This file
31+
32+
## Accessing Jenkins
33+
34+
After starting a tutorial with `docker compose --profile <name> up -d`:
35+
- Jenkins URL: `https://<codespace>-8080.<domain>` (shown in PORTS panel)
36+
- Default credentials: admin/admin
37+
38+
## Troubleshooting
39+
40+
**Port 8080 refuses connection:**
41+
- Ensure port visibility is set to **public** (see steps above)
42+
- Verify Jenkins is running: `docker compose ps`
43+
- Check logs: `docker compose logs jenkins_controller`
44+
45+
**Welcome message not showing:**
46+
- Run: `source ~/.bashrc` in your terminal
47+
- Or open a new terminal window
48+
49+
**yq not found:**
50+
- Run: `bash .devcontainer/setup.sh` manually

.devcontainer/setup.sh

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -92,3 +92,9 @@ if ! grep -q "Jenkins Quickstart Tutorials Welcome" ~/.bashrc; then
9292
echo " cat /workspaces/quickstart-tutorials/.devcontainer/welcome.txt" >> ~/.bashrc
9393
echo "fi" >> ~/.bashrc
9494
fi
95+
96+
# Set port 8080 visibility to public using gh CLI (if in Codespaces)
97+
if [ -n "$CODESPACE_NAME" ]; then
98+
echo "🔓 Setting port 8080 visibility to public..."
99+
gh codespace ports visibility 8080:public -c "$CODESPACE_NAME" 2>/dev/null || echo "⚠️ Could not set port visibility automatically. Please set port 8080 to public manually in the PORTS panel."
100+
fi

0 commit comments

Comments
 (0)