Skip to content
Closed
Show file tree
Hide file tree
Changes from 5 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
52 changes: 52 additions & 0 deletions .devcontainer/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
# Codespaces Configuration

This directory contains the GitHub Codespaces dev container configuration.

## Port Visibility Issue

If port 8080 shows as **private** after creating a Codespace, you need to manually change it to **public**:

### Manual Steps:
1. Open the **PORTS** panel at the bottom of VS Code (next to TERMINAL)
2. Find port **8080** in the list
3. **Right-click** on port 8080
4. Select **Port Visibility** → **Public**
5. Refresh your browser and access Jenkins

### Why is this needed?

The `devcontainer.json` includes `"visibility": "public"` for port 8080, but GitHub Codespaces may not always apply this setting automatically, especially:
- On the first Codespace creation
- If there's an organization policy
- If the port is forwarded before the container is fully started

The setup script attempts to set the port visibility automatically using the GitHub CLI, but if that fails, manual intervention is required.

## Files

- **devcontainer.json** - Dev container specification
- **setup.sh** - Initialization script (installs yq, configures URLs, creates welcome message)
- **welcome.txt** - Generated welcome message (not in git, created at runtime)
- **README.md** - This file

## Accessing Jenkins

After starting a tutorial with `docker compose --profile <name> up -d`:
- Jenkins URL: `https://<codespace>-8080.<domain>` (shown in PORTS panel)
- Default credentials: admin/admin

**Important:** Open Jenkins in a regular browser tab, not the VS Code preview pane. The preview may show "Please reopen the preview" due to Jenkins security headers. Click the globe icon 🌐 in the PORTS panel or copy the URL to your browser.

## Troubleshooting

**Port 8080 refuses connection:**
- Ensure port visibility is set to **public** (see steps above)
- Verify Jenkins is running: `docker compose ps`
- Check logs: `docker compose logs jenkins_controller`

**Welcome message not showing:**
- Run: `source ~/.bashrc` in your terminal
- Or open a new terminal window

**yq not found:**
- Run: `bash .devcontainer/setup.sh` manually
54 changes: 54 additions & 0 deletions .devcontainer/devcontainer.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
{
"name": "Jenkins Quickstart Tutorials",
"image": "mcr.microsoft.com/devcontainers/base:ubuntu-24.04",

"features": {
"ghcr.io/devcontainers/features/docker-in-docker:2": {
"version": "latest",
"dockerDashComposeVersion": "v2"
},
"ghcr.io/devcontainers/features/github-cli:1": {
"version": "latest"
}

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

For better reproducibility and to avoid unexpected breaking changes from automatic updates, it's a best practice to pin the versions of dev container features instead of using latest. You can find the latest stable versions on the respective feature's GitHub page.

Suggested change
"version": "latest",
"dockerDashComposeVersion": "v2"
},
"ghcr.io/devcontainers/features/github-cli:1": {
"version": "latest"
}
"version": "2.7.0",
"dockerDashComposeVersion": "v2"
},
"ghcr.io/devcontainers/features/github-cli:1": {
"version": "1.4.0"
}

},

"onCreateCommand": "bash .devcontainer/setup.sh",
"postStartCommand": "cat .devcontainer/welcome.txt 2>/dev/null || echo 'Run: .devcontainer/setup.sh for tutorial instructions'",

"forwardPorts": [8080, 3000, 5000],

"portsAttributes": {
"8080": {
"label": "Jenkins Controller",
"onAutoForward": "openBrowser",
"protocol": "http",
"visibility": "public"
},
"3000": {
"label": "Application Port (Node/Android/Go)",
"onAutoForward": "notify",
"protocol": "http"
},
"5000": {
"label": "Application Port (Multi/.NET)",
"onAutoForward": "notify",
"protocol": "http"
}
},

"customizations": {
"vscode": {
"extensions": [
"ms-azuretools.vscode-docker",
"redhat.vscode-yaml"
],
"settings": {
"terminal.integrated.defaultProfile.linux": "bash"
}
}
},

"remoteUser": "vscode",

"updateContentCommand": "echo 'Container updated successfully'"
}
100 changes: 100 additions & 0 deletions .devcontainer/setup.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,100 @@
#!/bin/bash
# GitHub Codespaces setup script for Jenkins Quickstart Tutorials
# This script configures the Codespace environment and prepares Jenkins URL configuration

set -e # Exit on error

echo "================================"
echo "Setting up Jenkins Tutorials Environment"
echo "================================"

# Install yq (YAML processor) - required for JCasc configuration
echo "📦 Installing yq YAML processor..."
sudo wget -qO /usr/local/bin/yq https://github.com/mikefarah/yq/releases/latest/download/yq_linux_amd64

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

To ensure reproducible builds and prevent unexpected issues from automatic updates, it's recommended to pin the version of yq being installed rather than fetching latest.

Suggested change
sudo wget -qO /usr/local/bin/yq https://github.com/mikefarah/yq/releases/latest/download/yq_linux_amd64
sudo wget -qO /usr/local/bin/yq https://github.com/mikefarah/yq/releases/download/v4.44.2/yq_linux_amd64

sudo chmod a+x /usr/local/bin/yq
yq --version

# Verify Docker is available
echo "🐳 Verifying Docker installation..."
docker --version
docker compose version

# Create secrets directory if it doesn't exist
echo "📁 Creating secrets directory..."
mkdir -p ./secrets

# Run Codespaces URL configuration script
if [ -f "./dockerfiles/codespacesURL.sh" ]; then
echo "🔧 Configuring Jenkins URLs for Codespaces..."
chmod +x ./dockerfiles/codespacesURL.sh
./dockerfiles/codespacesURL.sh
else
echo "⚠️ Warning: codespacesURL.sh not found, skipping URL configuration"
fi

# Create welcome message for future terminal sessions
WELCOME_FILE=".devcontainer/welcome.txt"
cat > "$WELCOME_FILE" << 'WELCOME_EOF'

================================
🚀 Jenkins Quickstart Tutorials
================================

Available tutorial profiles:
• default : Basic Jenkins with SSH agent
• maven : Jenkins + Maven build environment
• python : Jenkins + Python development
• node : Jenkins + Node.js/npm
• multi : Multibranch pipeline example
• android : Android development
• golang : Go development
• cpp : C++ development
• dotnet : .NET development
• wizard : Jenkins setup wizard (learning)

Quick Start:
docker compose --profile <profile-name> up -d

Examples:
docker compose --profile maven up -d
docker compose --profile node up -d

To build locally:
docker compose -f build-docker-compose.yaml --profile <profile-name> up -d

WELCOME_EOF

# Add Jenkins URL based on environment
if [ -n "$CODESPACE_NAME" ] && [ -n "$GITHUB_CODESPACES_PORT_FORWARDING_DOMAIN" ]; then
echo "Jenkins will be accessible at:" >> "$WELCOME_FILE"
echo " https://${CODESPACE_NAME}-8080.${GITHUB_CODESPACES_PORT_FORWARDING_DOMAIN}" >> "$WELCOME_FILE"
else
echo "Jenkins will be accessible at:" >> "$WELCOME_FILE"
echo " http://localhost:8080" >> "$WELCOME_FILE"
fi

echo "" >> "$WELCOME_FILE"
echo "Default credentials: admin/admin" >> "$WELCOME_FILE"
echo "================================" >> "$WELCOME_FILE"
echo "" >> "$WELCOME_FILE"

# Display the welcome message
cat "$WELCOME_FILE"

echo "✅ Setup Complete! Welcome message saved to $WELCOME_FILE"
echo ""

# Add welcome message to .bashrc so it shows on every new terminal
if ! grep -q "Jenkins Quickstart Tutorials Welcome" ~/.bashrc; then
echo "" >> ~/.bashrc
echo "# Jenkins Quickstart Tutorials Welcome" >> ~/.bashrc
echo "if [ -f /workspaces/quickstart-tutorials/.devcontainer/welcome.txt ]; then" >> ~/.bashrc
echo " cat /workspaces/quickstart-tutorials/.devcontainer/welcome.txt" >> ~/.bashrc

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

Instead of hardcoding the workspace path, it's more robust to use the $GITHUB_WORKSPACE environment variable, which is provided by GitHub Codespaces. This makes the script more portable. Using single quotes for the echo commands will ensure the variable is written to .bashrc literally and expanded upon sourcing the file.

Suggested change
echo "if [ -f /workspaces/quickstart-tutorials/.devcontainer/welcome.txt ]; then" >> ~/.bashrc
echo " cat /workspaces/quickstart-tutorials/.devcontainer/welcome.txt" >> ~/.bashrc
echo 'if [ -f "$GITHUB_WORKSPACE/.devcontainer/welcome.txt" ]; then' >> ~/.bashrc
echo ' cat "$GITHUB_WORKSPACE/.devcontainer/welcome.txt"' >> ~/.bashrc

echo "fi" >> ~/.bashrc
fi

# Set port 8080 visibility to public using gh CLI (if in Codespaces)
if [ -n "$CODESPACE_NAME" ]; then
echo "🔓 Setting port 8080 visibility to public..."
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."
fi
15 changes: 14 additions & 1 deletion .github/dependabot.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@
# https://docs.github.com/github/administering-a-repository/configuration-options-for-dependency-updates

version: 2
# Note: GitPod support is legacy (free tier sunset). Migrated to GitHub Codespaces.
# Codespaces uses devcontainer.json which Dependabot cannot monitor (not a Dockerfile).
# Manual updates for mcr.microsoft.com/devcontainers/base:ubuntu-24.04 as needed.

# Enable version updates for GitHub Actions workflows
updates:
- package-ecosystem: "github-actions"
Expand Down Expand Up @@ -62,4 +66,13 @@ updates:
directory: "./dockerfiles/dotnet"
schedule:
interval: weekly
open-pull-requests-limit: 10
open-pull-requests-limit: 10

# GitPod (legacy) - disabled, not actively maintained
- package-ecosystem: docker
directory: "./.gitpod"
schedule:
interval: weekly
open-pull-requests-limit: 0
ignore:
- dependency-name: "gitpod/workspace-full"
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,7 @@ secrets/*
03_maven_tutorial/secrets/*
.tutorial_running.txt

# Local development files
CLAUDE.md
CONTEXT.md
.devcontainer/welcome.txt
Loading
Loading