|
| 1 | + |
| 2 | +# Jenkins CI/CD Lab for Pipeline-Forge |
| 3 | + |
| 4 | +This directory contains a local Jenkins setup for experimenting with CI/CD Jenkins pipelines for the Pipeline-Forge project. |
| 5 | + |
| 6 | +## Overview |
| 7 | + |
| 8 | +This lab environment provides a quick way to spin up Jenkins locally using Kubernetes (kind or minikube) and configure it with Jenkins Configuration as Code (JCasc). |
| 9 | + |
| 10 | +The goal is to test and develop CI/CD pipelines for Pipeline-Forge components, evaluating Jenkins solutions and features. |
| 11 | + |
| 12 | +## Quick Start |
| 13 | + |
| 14 | +### Prerequisites |
| 15 | + |
| 16 | +- `kubectl` |
| 17 | +- `helm` |
| 18 | +- `docker` |
| 19 | +- Either `kind` or `minikube` |
| 20 | + |
| 21 | +### Installation |
| 22 | + |
| 23 | +Run the bootstrap script to create a local Jenkins instance: |
| 24 | + |
| 25 | +```bash |
| 26 | +# Kind by default |
| 27 | +./bootstrap_jenkins.sh |
| 28 | + |
| 29 | +# or specify minikube |
| 30 | +./bootstrap_jenkins.sh minikube |
| 31 | +``` |
| 32 | + |
| 33 | +The script will: |
| 34 | +1. Create a local Kubernetes cluster |
| 35 | +2. Set up the `jenkins` namespace with required RBAC and storage |
| 36 | +3. Install Jenkins via Helm with JCasc configuration |
| 37 | +4. Wait for Jenkins to be ready |
| 38 | + |
| 39 | + |
| 40 | +After the installation completes: |
| 41 | + |
| 42 | +1. **Port forward to Jenkins:** |
| 43 | + ```bash |
| 44 | + kubectl port-forward svc/jenkins -n jenkins 8080:8080 |
| 45 | + ``` |
| 46 | + |
| 47 | +2. **Get the admin password:** |
| 48 | + ```bash |
| 49 | + kubectl get secret -n jenkins jenkins -o jsonpath={.data.jenkins-admin-password} | base64 --decode |
| 50 | + ``` |
| 51 | + |
| 52 | +## Bootstrapping Pipelines |
| 53 | + |
| 54 | +**⚠️ Important:** After Jenkins is installed, you need to manually run the seed job to bootstrap all pipelines. |
| 55 | + |
| 56 | +**Steps:** |
| 57 | +1. Navigate to Jenkins UI |
| 58 | +2. Locate and run the seed job (configured via JCasc) |
| 59 | +3. This will create all Pipeline-Forge CI/CD pipelines (work in progress) |
| 60 | + |
| 61 | + |
| 62 | +## Cleanup |
| 63 | + |
| 64 | +Delete the local Jenkins cluster: |
| 65 | +```bash |
| 66 | +kind delete cluster --name jenkins |
| 67 | +# or |
| 68 | +minikube delete -p jenkins-control-plane |
| 69 | +``` |
| 70 | + |
| 71 | +## Lab Implementation Notes |
| 72 | + |
| 73 | +Compared to the [upstream Jenkins Helm chart defaults](https://raw.githubusercontent.com/jenkinsci/helm-charts/main/charts/jenkins/values.yaml), this lab includes: |
| 74 | + |
| 75 | +**Seed Job via JCasC** |
| 76 | +A seed pipeline job is defined via Jenkins Configuration as Code |
| 77 | +- The seed job pulls the Pipeline-Forge repository and bootstraps Jenkins CI pipelines from repository-managed definitions |
| 78 | + |
| 79 | +**Two-Step Bootstrap (Intentional Design)** |
| 80 | +- Jenkins installation and CI/CD pipeline creation are deliberately separated |
| 81 | +- Keeps bootstrap logs clean and avoids hiding configuration issues |
| 82 | +- Allows you to debug seed job errors without re-running the entire cluster setup |
| 83 | +- Enables independent iteration on CI/CD pipeline definitions |
| 84 | + |
| 85 | +**CI-Focused Plugin Set** |
| 86 | +- Additional plugins for multibranch pipelines, GitHub integration, Job DSL, Kubernetes agents, and JCasC |
| 87 | + |
| 88 | +**Job DSL Script Security** |
| 89 | +- Script security for Job DSL is disabled via init script to allow seed job execution without needing manual approval |
| 90 | +- Can be manually re-enabled in Jenkins UI (Manage Jenkins → Configure System → Job DSL) after the initial seed job completes if required |
| 91 | + |
| 92 | +**Local-First Defaults** |
| 93 | +- Jenkins URL: `http://localhost:8080` |
| 94 | +- Access via port-forwarding with no external service |
| 95 | + |
| 96 | +**Configuration** |
| 97 | + |
| 98 | +Override values are defined in `values.lab.yaml`. |
| 99 | + |
| 100 | +**Note:** Plugin versions are intentionally unpinned for this development environment to always pull the latest versions. |
| 101 | + |
| 102 | +### References |
| 103 | + |
| 104 | +- [Installing Jenkins on Kubernetes](https://www.jenkins.io/doc/book/installing/kubernetes/#install-jenkins) |
| 105 | +- [Jenkins Helm Chart Default Values](https://raw.githubusercontent.com/jenkinsci/helm-charts/main/charts/jenkins/values.yaml) |
0 commit comments