100 days of devops - Day 79: Jenkins Deployment Job

Jenkins Auto Deployment Task – Validation Failed (Need Help)

Task Objective

The goal of this task was to configure a Jenkins job to automatically deploy an application when changes are pushed to a Git repository.

Requirements:

  1. Ensure httpd is running on App Server 1 (port 8080).

  2. Create a Jenkins job:

    • Name: nautilus-app-deployment
    • Trigger: automatic deployment on push to master branch
  3. Deploy application to:

    /var/www/html
    
  4. Ensure ownership of /var/www/html is set to user sarah.

  5. Modify index.html with:

    Welcome to the xFusionCorp Industries
    
  6. Push changes → Jenkins should trigger automatically → deploy code.

  7. Application should be accessible via:

    http://stlb01:8091
    

What I Implemented

Jenkins Configuration

  • Job type: Freestyle

  • SCM: Git

    • Repo: sarah/web
    • Branch: */master
  • Trigger:

    • Webhook (GitHub hook trigger for GITScm polling)
  • Node:

    • Runs on app-server
  • Build Step:

sudo chown -R sarah:sarah /var/www/html
sudo rm -rf /var/www/html/*
sudo cp -r index.html /var/www/html/
sudo systemctl restart httpd

Webhook

  • Configured in Gitea:
/github-webhook/
  • Jenkins receives push events and triggers job successfully.

Verification

After pushing changes:

curl http://localhost:8080
curl http://stlb01:8091

Output:

Welcome to the xFusionCorp Industries

Jenkins build log:

Started by remote host
Finished: SUCCESS

Issue Faced

Despite everything working correctly, validation fails with:

Validation file not on LB. Check webhook triggers the job and job deploys to /var/www/html.

Root Cause (Identified)

My deployment command was:

sudo cp -r index.html /var/www/html/

This copies only index.html.

However, during validation, the system pushes an additional file (validation file) to the repository.

Since my job copies only one file, the validator file is not deployed, causing failure.


Fix Applied

Updated build script to deploy entire repository:

sudo chown -R sarah:sarah /var/www/html
sudo rm -rf /var/www/html/*
sudo cp -r * /var/www/html/
sudo systemctl restart httpd

Current Status

  • Jenkins triggers automatically on push :heavy_check_mark:
  • Deployment works :heavy_check_mark:
  • Application accessible via Load Balancer :heavy_check_mark:
  • Still waiting to confirm validator passes after fix :question:

Question

Is there anything else required by the validator besides:

  • Deploying full repository content
  • Using webhook trigger
  • Serving from /var/www/html

Or is the issue only due to copying a single file earlier?

Hi @hazem

There is a solution for this task, have you checked it before?