DEV Community

Wycliffe A. Onyango
Wycliffe A. Onyango

Posted on

100 Days of DevOps: Day 77

CI/CD Deployment of Web Application using Jenkins Pipeline

Objective

Automate deployment of a static website from a Gitea repository to the shared document root on the Storage Server using a Jenkins Pipeline with a single stage named Deploy.


Work Completed

1. Jenkins UI Access

Jenkins was already installed and running. Configuration was performed through the Jenkins web interface:

Login credentials:

  • Username: admin
  • Password: Adm!n321

No Jenkins server installation steps were required.


2. Required Jenkins Plugin Installation

Several plugins needed for source code retrieval and pipeline execution were installed from:

Manage Jenkins → Plugins → Available Plugins

Installed:

  • Git plugin
  • SSH Agent plugin
  • Pipeline plugin

Jenkins was restarted from the UI to apply the changes.


3. Java 21 Installation

Java was required for proper Jenkins agent execution. On the Storage Server, Java 21 was installed using:

sudo dnf install -y java-21-openjdk
java -version
Enter fullscreen mode Exit fullscreen mode

Java installed successfully.


4. Add Storage Server as Jenkins Agent

Jenkins needed a remote execution environment to deploy directly to the shared site directory.

Performed via:
Manage Jenkins → Nodes → New Node

Configuration:

  • Node name: Storage Server
  • Remote root directory: /var/www/html/workspace
  • Label: ststor01
  • Launch method: Launch agent via execution of command on the agent node

Jenkins generated a command, which was executed on the Storage Server to bring the agent online.

Credentials Setup

Under:
Manage Jenkins → Credentials

A secure SSH credential was added to allow the controller to authenticate to the Storage Server. This ensured a reliable and secure connection for deployments.


5. Folder Permissions on Storage Server

To allow Jenkins agent to write deployed files:

sudo chown -R natasha:natasha /var/www/html
sudo chmod -R 755 /var/www/html
Enter fullscreen mode Exit fullscreen mode

This ensured successful delivery of web content.


6. Create Jenkins Pipeline Job

Job Type: Pipeline
Job Name: xfusion-webapp-job
(Not a Multibranch Pipeline)

Pipeline Script Used

pipeline {
    agent { label 'ststor01' }
    stages {
        stage('Deploy') {
            steps {
                git url: 'https://80-port-qtjnzi2lylpawcus.labs.kodekloud.com/sarah/web_app'
                sh 'cp -r index.html /var/www/html/'
            }
        }
    }
}
Enter fullscreen mode Exit fullscreen mode

Details:

  • Single stage named Deploy (case-sensitive requirement met)
  • Pulls source code from web_app repository in Gitea
  • Deployed directly to final document root

7. Successful Deployment Execution

Triggered via Build Now.

Console output confirmed:

  • Git repository successfully cloned
  • Deployment action executed on Storage Server
  • index.html delivered properly

Final status: SUCCESS

The website displayed correctly via the Load Balancer main URL without extra subdirectories.


Final Result

A complete CI/CD deployment pipeline now updates the website automatically with each build. The system uses:

  • A Jenkins pipeline job
  • SSH connected Storage Server agent
  • Secure credentials
  • Direct deployment to /var/www/html

This enables developers to publish updates efficiently and consistently.

result

Top comments (0)