This project is a beginner-friendly frontend application built with React and Vite, then wired into a complete DevOps workflow using:
- GitHub for source control
- Jenkins for CI/CD
- ESLint for code quality
- Trivy for vulnerability scanning
- Docker for containerization
- Docker Hub for image publishing
- Vercel for deployment
The repository includes two separate declarative Jenkins pipelines:
Jenkinsfile.full: runs the complete flow including Docker Hub pushJenkinsfile.no-docker-push: runs the same flow but skips the Docker push stage
react-devops-cicd/
├── Dockerfile
├── .dockerignore
├── Jenkinsfile.full
├── Jenkinsfile.no-docker-push
├── eslint.config.js
├── package.json
├── src/
│ ├── App.jsx
│ ├── App.css
│ ├── index.css
│ └── main.jsx
└── README.md
- React + Vite frontend app
- Clean responsive UI
- Example API fetch using
https://jsonplaceholder.typicode.com/posts?_limit=3 - Production-ready
npm run build - ESLint support
- Trivy filesystem scan in Jenkins
- Docker image build
- Vercel deployment from Jenkins
Install these tools first:
- Node.js 20+
- npm
- Docker Desktop
- Jenkins
- Trivy
- Vercel CLI
- Git
Helpful macOS commands:
brew install node
brew install trivy
npm install -g vercelInstall Jenkins with Homebrew:
brew install jenkins-lts
brew services start jenkins-ltsJenkins usually opens at:
http://localhost:8080
npm ci
npm run devOpen:
http://localhost:5173
npm run lint
npm run buildBuild the Docker image:
docker build -t react-vite-devops-cicd .Run the container:
docker run -d -p 8081:80 react-vite-devops-cicdOpen:
http://localhost:8081
Login once:
vercel loginDeploy manually from your terminal:
vercelDeploy to production:
vercel --prodIf you want the repo linked first:
vercel linkStages:
- Clone repository
- Install npm dependencies
- Run ESLint
- Run Trivy filesystem scan
- Build React/Vite app
- Build Docker image
- Push Docker image to Docker Hub
- Deploy to Vercel
Stages:
- Clone repository
- Install npm dependencies
- Run ESLint
- Run Trivy filesystem scan
- Build React/Vite app
- Build Docker image
- Deploy to Vercel
This second pipeline skips only the Docker push stage.
Inside Jenkins, install:
- Pipeline
- Git
- GitHub Integration
- Credentials Binding
- Docker Pipeline
- Workspace Cleanup
Go to:
Manage Jenkins -> Credentials -> System -> Global credentials
Create these credentials as Secret text entries:
| Credential ID | Purpose |
|---|---|
dockerhub-username |
Your Docker Hub username |
dockerhub-password |
Your Docker Hub password or access token |
vercel-token |
Your Vercel access token |
vercel-org-id |
Your Vercel organization/team ID |
vercel-project-id |
Your Vercel project ID |
You can find your Vercel token from the Vercel dashboard.
To get the Vercel project metadata locally after linking:
cat .vercel/project.jsonExample file content:
{
"projectId": "prj_xxxxxxxxxxxxx",
"orgId": "team_xxxxxxxxxxxxx"
}- In Jenkins, click
New Item - Enter a job name such as
react-vite-full-pipeline - Choose
Pipeline - Under
Pipeline Definition, choosePipeline script from SCM - Choose
Git - Add your GitHub repository URL
- Set
Script Pathto either:Jenkinsfile.fullJenkinsfile.no-docker-push
- Save the job
To trigger Jenkins automatically after each push:
- Open your GitHub repository
- Go to
Settings -> Webhooks - Click
Add webhook - Use this payload URL:
http://YOUR_JENKINS_URL/github-webhook/
Examples:
http://localhost:8080/github-webhook/
http://your-public-jenkins-domain/github-webhook/
- Set
Content typeto:
application/json
- Choose:
Just the push event
- Save the webhook
Inside Jenkins job configuration, also enable:
GitHub hook trigger for GITScm polling
The pipelines use these environment variables:
DOCKER_IMAGE_NAMEDOCKERHUB_USERNAMEVERCEL_TOKEN
The Vercel CLI stage also expects:
VERCEL_ORG_IDVERCEL_PROJECT_ID
The pipelines run this command:
trivy fs --scanners vuln,secret,misconfig --severity HIGH,CRITICAL --exit-code 1 --no-progress .This fails the build if Trivy finds high or critical issues.
The Jenkins machine or agent should have:
- Git
- Node.js and npm
- Docker
- Trivy
- Internet access for npm and Vercel CLI
Quick verification commands:
node -v
npm -v
docker --version
trivy --versionTypical flow:
- Push code to GitHub
- GitHub webhook notifies Jenkins
- Jenkins runs one of the pipeline files
- Jenkins lints, scans, builds, packages, and deploys
- Vercel publishes the frontend
- Use
npm ciin CI because it is faster and more predictable thannpm install - Docker Hub often works best with an access token instead of your password
- Vercel deployment from CI is easiest after running
vercel linkonce locally - If Trivy is not installed on your Jenkins machine, the scan stage will fail until you install it
- If Docker is not running, the Docker build stage will fail
Run locally:
npm ci
npm run devCheck lint:
npm run lintBuild app:
npm run buildBuild Docker image:
docker build -t react-vite-devops-cicd .Run Docker container:
docker run -p 8081:80 react-vite-devops-cicdDeploy with Vercel CLI:
vercel --prod