This repository uses GitHub Actions to automatically validate and deploy Jenkins Job Builder (JJB) configurations.
Two Workflows:
- Validation (
test.yaml) - Runs on Pull Requests - Deployment (
deploy.yaml) - Runs on merge tocentos-cibranch
Simple Flow:
Developer → Pull Request → test.yaml (Validate) → Merge → deploy.yaml (Deploy) → Jenkins Updated
Trigger: Pull Request to any branch
What it does:
- Builds Docker container with JJB
- Validates YAML syntax
- Checks macro references
- Does NOT connect to Jenkins
File: .github/workflows/test.yaml
on:
pull_request:
branches: ['*']
steps:
- Checkout code
- Build Docker image
- Run: jenkins-jobs test (validation only)Trigger: Push to centos-ci branch
What it does:
- Builds Docker container with JJB
- Injects Jenkins API key
- Connects to Jenkins
- Creates/updates jobs
File: .github/workflows/deploy.yaml
on:
push:
branches: ['centos-ci']
steps:
- Checkout code
- Build Docker image
- Run: jenkins-jobs update (actual deployment)Docker image with JJB installed
jenkins-jobs test globals/macros:jobsValidates syntax without Jenkins connection
sed "s/JENKINS_API_KEY/$JENKINS_API_KEY/g" tests/jenkins.conf > jobs/jenkins.ini
jenkins-jobs --conf jobs/jenkins.ini update jobs/:globals/macros/Injects API key and deploys to Jenkins
JJB configuration template with API key placeholder
Reusable JJB templates (SCM, parameters, triggers, etc.)
Jenkins job definitions using JJB format
Pull Request
↓
test.yaml → Containerfile → verify-yaml.sh → JJB (test mode)
↓
Validation Result → PR Status Check
Merge to centos-ci
↓
deploy.yaml → Containerfile → deploy-nfs-ganesha-ci.sh
↓
jenkins.conf + API Key → JJB (update mode)
↓
macros.yml + jobs/jjb/*.yaml → Jenkins API
↓
Jobs Created/Updated in Jenkins
# 1. Build container
docker build -t nfs-ganesha-ci-tests -f tests/Containerfile .
# 2. Test validation (like test.yaml)
docker run --rm nfs-ganesha-ci-tests:latest
# 3. Generate XML preview
docker run --rm -v $(pwd)/output:/output nfs-ganesha-ci-tests:latest sh -c \
"jenkins-jobs test globals/macros:jobs/jjb -o /output --config-xml"
# 4. View generated XML
cat output/*/config.xml
# 5. Deploy to Jenkins (requires API key)
docker run --rm --env="JENKINS_API_KEY=your-token" \
--entrypoint=tests/deploy-nfs-ganesha-ci.sh \
nfs-ganesha-ci-tests:latestJenkins Server: https://jenkins-nfs-ganesha.apps.ocp.cloud.ci.centos.org
Test locally: docker run --rm nfs-ganesha-ci-tests:latest
Deploy: Push to centos-ci branch
