-
Couldn't load subscription status.
- Fork 302
feat: migrate to GitHub Codespaces for weekly branch #1684
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
gounthar
merged 4 commits into
jenkins-docs:weekly
from
gounthar:feature/codespaces-migration-weekly
Oct 15, 2025
Merged
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
de85754
feat: add GitHub Codespaces support for cloud development
gounthar 58aa8d3
chore: mark GitPod configuration as legacy in dependabot
gounthar 5bb82d4
feat(updatecli): add automatic tracking for devcontainer dependencies
gounthar 4f68259
fix(updatecli): improve GitHub CLI version filter pattern
gounthar File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,49 @@ | ||
| # Codespaces Configuration | ||
|
|
||
| This directory contains the GitHub Codespaces dev container configuration. | ||
|
|
||
| ## Port Visibility | ||
|
|
||
| Port 8080 may show as **private** in the PORTS panel, but this is usually not an issue - you can still access Jenkins using the forwarded URL. | ||
|
|
||
| **Note:** The port visibility label in the UI can be misleading. Even when marked as "private", the Jenkins URL provided in the welcome message will work in your browser. Only change visibility to "public" if you need to share the URL with others. | ||
|
|
||
| ### Manual Steps (if needed for sharing): | ||
| 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** | ||
|
|
||
| ### Technical Details | ||
|
|
||
| The `devcontainer.json` includes `"visibility": "public"` for port 8080, but GitHub Codespaces may not always apply this setting automatically. The setup script attempts to set visibility using the GitHub CLI, but this is optional since Codespaces authentication allows private port access. | ||
|
|
||
| ## 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:** | ||
| - Verify Jenkins is running: `docker compose ps` | ||
| - Check logs: `docker compose logs jenkins_controller` | ||
| - Wait 1-2 minutes for Jenkins to fully start | ||
| - Port visibility (private/public) should not affect access for the Codespace owner | ||
|
|
||
| **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 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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": "27.0", | ||
| "dockerDashComposeVersion": "v2" | ||
| }, | ||
| "ghcr.io/devcontainers/features/github-cli:1": { | ||
| "version": "2.62" | ||
| } | ||
| }, | ||
|
|
||
| "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'" | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,121 @@ | ||
| #!/usr/bin/env bash | ||
| # GitHub Codespaces setup script for Jenkins Quickstart Tutorials | ||
| # This script configures the Codespace environment and prepares Jenkins URL configuration | ||
|
|
||
| set -Eeuo pipefail # Exit on error, undefined variables, pipe failures | ||
|
|
||
| echo "================================" | ||
| echo "Setting up Jenkins Tutorials Environment" | ||
| echo "================================" | ||
|
|
||
| # Install yq (YAML processor) - required for JCaC configuration | ||
| echo "📦 Installing yq YAML processor..." | ||
| YQ_VERSION="${YQ_VERSION:-v4.44.3}" | ||
| YQ_URL="https://github.com/mikefarah/yq/releases/download/${YQ_VERSION}/yq_linux_amd64" | ||
|
|
||
| # Try wget first, fall back to curl if unavailable | ||
| if command -v wget &> /dev/null; then | ||
| sudo wget -qO /usr/local/bin/yq "${YQ_URL}" | ||
| elif command -v curl &> /dev/null; then | ||
| sudo curl -fsSL -o /usr/local/bin/yq "${YQ_URL}" | ||
| else | ||
| echo "❌ Error: Neither wget nor curl found. Cannot download yq." | ||
| exit 1 | ||
| fi | ||
|
|
||
| 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 | ||
| # Use git rev-parse to find repo root dynamically instead of hardcoding path | ||
| REPO_ROOT="$(git rev-parse --show-toplevel 2>/dev/null || pwd)" | ||
| WELCOME_PATH="${REPO_ROOT}/.devcontainer/welcome.txt" | ||
|
|
||
| if ! grep -q "Jenkins Quickstart Tutorials Welcome" ~/.bashrc; then | ||
| echo "" >> ~/.bashrc | ||
| echo "# Jenkins Quickstart Tutorials Welcome" >> ~/.bashrc | ||
| echo "if [ -f \"${WELCOME_PATH}\" ]; then" >> ~/.bashrc | ||
| echo " cat \"${WELCOME_PATH}\"" >> ~/.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..." | ||
| # Check if gh CLI is authenticated before attempting to set port visibility | ||
| if gh auth status &>/dev/null; then | ||
| 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." | ||
| else | ||
| echo "⚠️ gh CLI not authenticated. Please set port 8080 to public manually in the PORTS panel." | ||
| fi | ||
| fi | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The yq version is hardcoded here but also managed in updatecli/updatecli.d/devcontainer.yaml. This creates a potential inconsistency. Consider making this script read the version from devcontainer.json or another single source of truth to avoid version drift.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@copilot Thanks for the review! I understand the concern about version consistency, but this design is intentional.
How version management works:
This repository uses UpdateCLI for automated dependency tracking. The yq version is managed in
updatecli/updatecli.d/devcontainer.yaml:Why not read from devcontainer.json?
Circular dependency: Your suggestion requires
jqto be pre-installed in the devcontainer base image. Ifjqis missing, the setup fails entirely.Single source of truth: UpdateCLI IS the single source of truth. It automatically updates this file when new yq versions are released.
Simplicity: Direct version variable is easier to override (
YQ_VERSION=v4.50.0 bash setup.sh) and debug.No runtime parsing: The current approach doesn't require parsing JSON at runtime, making it faster and more reliable.
The UpdateCLI workflow:
.devcontainer/setup.shThis is a common pattern for managing dependencies in infrastructure-as-code. The version appears "hardcoded" but is actually managed by automation.
See
updatecli/updatecli.d/devcontainer.yamlfor the full configuration.