|
| 1 | +#!/bin/bash |
| 2 | +# GitHub Codespaces setup script for Jenkins Quickstart Tutorials |
| 3 | +# This script configures the Codespace environment and prepares Jenkins URL configuration |
| 4 | + |
| 5 | +set -e # Exit on error |
| 6 | + |
| 7 | +echo "================================" |
| 8 | +echo "Setting up Jenkins Tutorials Environment" |
| 9 | +echo "================================" |
| 10 | + |
| 11 | +# Install yq (YAML processor) - required for JCasc configuration |
| 12 | +echo "📦 Installing yq YAML processor..." |
| 13 | +sudo wget -qO /usr/local/bin/yq https://github.com/mikefarah/yq/releases/latest/download/yq_linux_amd64 |
| 14 | +sudo chmod a+x /usr/local/bin/yq |
| 15 | +yq --version |
| 16 | + |
| 17 | +# Verify Docker is available |
| 18 | +echo "🐳 Verifying Docker installation..." |
| 19 | +docker --version |
| 20 | +docker compose version |
| 21 | + |
| 22 | +# Create secrets directory if it doesn't exist |
| 23 | +echo "📁 Creating secrets directory..." |
| 24 | +mkdir -p ./secrets |
| 25 | + |
| 26 | +# Run Codespaces URL configuration script |
| 27 | +if [ -f "./dockerfiles/codespacesURL.sh" ]; then |
| 28 | + echo "🔧 Configuring Jenkins URLs for Codespaces..." |
| 29 | + chmod +x ./dockerfiles/codespacesURL.sh |
| 30 | + ./dockerfiles/codespacesURL.sh |
| 31 | +else |
| 32 | + echo "⚠️ Warning: codespacesURL.sh not found, skipping URL configuration" |
| 33 | +fi |
| 34 | + |
| 35 | +# Create welcome message for future terminal sessions |
| 36 | +WELCOME_FILE=".devcontainer/welcome.txt" |
| 37 | +cat > "$WELCOME_FILE" << 'WELCOME_EOF' |
| 38 | +
|
| 39 | +================================ |
| 40 | +🚀 Jenkins Quickstart Tutorials |
| 41 | +================================ |
| 42 | +
|
| 43 | +Available tutorial profiles: |
| 44 | + • default : Basic Jenkins with SSH agent |
| 45 | + • maven : Jenkins + Maven build environment |
| 46 | + • python : Jenkins + Python development |
| 47 | + • node : Jenkins + Node.js/npm |
| 48 | + • multi : Multibranch pipeline example |
| 49 | + • android : Android development |
| 50 | + • golang : Go development |
| 51 | + • cpp : C++ development |
| 52 | + • dotnet : .NET development |
| 53 | + • wizard : Jenkins setup wizard (learning) |
| 54 | +
|
| 55 | +Quick Start: |
| 56 | + docker compose --profile <profile-name> up -d |
| 57 | +
|
| 58 | +Examples: |
| 59 | + docker compose --profile maven up -d |
| 60 | + docker compose --profile node up -d |
| 61 | +
|
| 62 | +To build locally: |
| 63 | + docker compose -f build-docker-compose.yaml --profile <profile-name> up -d |
| 64 | +
|
| 65 | +WELCOME_EOF |
| 66 | + |
| 67 | +# Add Jenkins URL based on environment |
| 68 | +if [ -n "$CODESPACE_NAME" ] && [ -n "$GITHUB_CODESPACES_PORT_FORWARDING_DOMAIN" ]; then |
| 69 | + echo "Jenkins will be accessible at:" >> "$WELCOME_FILE" |
| 70 | + echo " https://${CODESPACE_NAME}-8080.${GITHUB_CODESPACES_PORT_FORWARDING_DOMAIN}" >> "$WELCOME_FILE" |
| 71 | +else |
| 72 | + echo "Jenkins will be accessible at:" >> "$WELCOME_FILE" |
| 73 | + echo " http://localhost:8080" >> "$WELCOME_FILE" |
| 74 | +fi |
| 75 | + |
| 76 | +echo "" >> "$WELCOME_FILE" |
| 77 | +echo "Default credentials: admin/admin" >> "$WELCOME_FILE" |
| 78 | +echo "================================" >> "$WELCOME_FILE" |
| 79 | +echo "" >> "$WELCOME_FILE" |
| 80 | + |
| 81 | +# Display the welcome message |
| 82 | +cat "$WELCOME_FILE" |
| 83 | + |
| 84 | +echo "✅ Setup Complete! Welcome message saved to $WELCOME_FILE" |
| 85 | +echo "" |
0 commit comments