Skip to content

Latest commit

 

History

History
238 lines (158 loc) · 9.11 KB

File metadata and controls

238 lines (158 loc) · 9.11 KB

Jenkins Freestyle Project Implementation Report

Project Overview

This report documents the creation of a Jenkins Freestyle project with GitHub integration and automated webhook triggers. All steps include verification checkpoints and the actual outcomes.

Prerequisites

  • Jenkins Server: The project was executed on a server running at http://your-server-ip:8080.
  • GitHub Account: A GitHub account with repository creation permissions was used.
  • Network Access: The Jenkins server was configured to be accessible from GitHub webhooks.

Implementation Steps

1. Jenkins Freestyle Job Creation

Step 1.1: Accessed Jenkins Dashboard

First, I navigated to the Jenkins URL, logged in with admin credentials, and verified the dashboard displayed successfully.

Jenkins Dashboard Expected: Main dashboard with "New Item" visible in left menu

Step 1.2: Created New Freestyle Project

A new project was started by clicking "New Item". I entered the job name my-first-job, selected "Freestyle project", and clicked "OK".

Creating Freestyle Project Expected: Job creation form with name field and project type selection

Step 1.3: Performed Initial Job Configuration

On the configuration page, I added the description "First Jenkins freestyle project for CI/CD automation" and saved the configuration, leaving the other settings at their defaults.

Job Configuration Page Expected: Configuration page with multiple sections (General, Source Code Management, Build Triggers, etc.)

Step 1.4: Verified Job Creation

Returning to the dashboard, my-first-job was visible in the project list with an initial status of "Never built".

Job Created Successfully Expected: Dashboard showing newly created job in project list

2. GitHub Repository Setup

Step 2.1: Created GitHub Repository

I logged into GitHub and created a new repository named jenkins-scm, initializing it with a README file.

GitHub Repository Creation Expected: New repository with README.md file visible

Step 2.2: Copied Repository URL

The HTTPS URL for the new repository (https://github.com/username/jenkins-scm.git) was copied for use in the Jenkins configuration.

Repository URL Expected: Repository page with clone URL visible

3. Connecting Jenkins to GitHub

Step 3.1: Configured Source Code Management

In the my-first-job configuration, I navigated to the "Source Code Management" section, selected "Git", and pasted the copied repository URL. The "Branch Specifier" was left as */main.

SCM Configuration Expected: Git configuration section with repository URL filled

Step 3.2: Tested Repository Connection with a Manual Build

After saving the SCM configuration, I initiated a manual build by clicking "Build Now" from the job page.

Manual Build Execution Expected: Build #1 appears in build history

Step 3.3: Verified Build Success

I checked the "Console Output" for the first build and confirmed that the repository checkout was successful.

Build Console Output Expected: Console showing successful Git clone and checkout completion

Sample Console Output from Manual Build:

The following output confirms a successful connection and checkout from the GitHub repository.

Started by user admin
Running as SYSTEM
Building in workspace /var/jenkins_home/workspace/my-first-job
The recommended git tool is: NONE
using credential
 > git rev-parse --resolve-git-dir /var/jenkins_home/workspace/my-first-job/.git
Fetching changes from the remote Git repository
 > git config remote.origin.url https://github.com/username/jenkins-scm.git
Fetching upstream changes from https://github.com/username/jenkins-scm.git
 > git --version
 > git --version
 > git fetch --tags --force --progress -- https://github.com/username/jenkins-scm.git +refs/heads/*:refs/remotes/origin/*
 > git rev-parse refs/remotes/origin/main^{commit}
Checking out Revision abc123def456 (refs/remotes/origin/main)
 > git config core.sparsecheckout
 > git checkout -f abc123def456
Commit message: "Initial commit"
First time build. Skipping changelog.
Finished: SUCCESS

4. Configuring Automated Build Triggers

Step 4.1: Enabled GitHub Webhook Trigger in Jenkins

In the my-first-job configuration, under the "Build Triggers" section, I checked the box for "GitHub hook trigger for GITScm polling" and saved the change.

Build Triggers Setup Expected: Build Triggers section with GitHub webhook option enabled

Step 4.2: Configured Webhook in GitHub

In the GitHub repository's Settings, under "Webhooks", I added a new webhook. The configuration was as follows:

  • Payload URL: http://jenkins-ip:8080/github-webhook/
  • Content type: application/json
  • Events: "Just the push event" was selected.
  • Active: The webhook was set to active.

GitHub Webhook Configuration Expected: Webhook configuration form with Jenkins payload URL

Step 4.3: Tested the Automated Trigger

To test the webhook, I edited the README.md file directly in the GitHub repository and committed the change to the main branch.

GitHub File Edit Expected: GitHub file editor with changes ready to commit

Step 4.4: Verified Automatic Build

Upon returning to the Jenkins dashboard, a new build for my-first-job had been triggered automatically by the push to the GitHub repository.

Automatic Build Triggered Expected: New build (#2) appears automatically in build history

Troubleshooting Guide

This section documents potential issues and their resolutions based on the implementation.

Issue: Job Creation Fails

Symptoms: Error message when clicking "OK" Solutions:

  • Verify Jenkins has sufficient disk space
  • Check job name contains only valid characters (letters, numbers, hyphens)
  • Restart Jenkins service if persistent issues occur

Issue: GitHub Repository Not Accessible

Symptoms: "Failed to connect to repository" error Solutions:

  • Verify repository URL syntax: https://github.com/username/repo.git
  • Check repository visibility (public vs private)
  • Configure GitHub credentials in Jenkins if repository is private
  • Test network connectivity: curl -I https://github.com

Issue: Build Fails with Git Errors

Symptoms: Console shows Git command failures Solutions:

  • Verify Git is installed on Jenkins server
  • Check branch name matches repository default branch
  • Ensure Jenkins user has Git access permissions
  • Clear workspace and retry build

Issue: Webhook Not Triggering Builds

Symptoms: Manual builds work, but GitHub pushes don't trigger builds Solutions:

  • Verify webhook URL format: http://jenkins-ip:8080/github-webhook/
  • Check Jenkins server accessibility from internet
  • Confirm webhook shows green checkmark in GitHub
  • Review webhook delivery logs in GitHub settings
  • Ensure firewall allows inbound traffic on port 8080

Issue: Webhook SSL/TLS Errors

Symptoms: GitHub webhook delivery fails with SSL errors Solutions:

  • Use HTTP instead of HTTPS for initial testing
  • Configure proper SSL certificates on Jenkins
  • Add GitHub IPs to firewall whitelist
  • Test webhook delivery manually from GitHub interface

Issue: Build Queue Stuck

Symptoms: Builds remain in queue without executing Solutions:

  • Check Jenkins executors availability
  • Verify no jobs blocking the queue
  • Restart Jenkins service if needed
  • Monitor system resources (CPU, memory, disk)

Final State Verification

The following items confirm the successful completion of the project:

  • Jenkins dashboard is accessible and functional.
  • my-first-job is created and visible in the project list.
  • GitHub repository jenkins-scm was created with a README.md.
  • SCM configuration points to the correct repository URL.
  • A manual build was executed successfully.
  • The console output showed a successful Git checkout.
  • A GitHub webhook was configured with the correct payload URL.
  • The webhook delivery showed a successful ping.
  • A file modification in GitHub triggered an automatic build.
  • The build history shows both manual and automatic builds.

Expected Results Summary

This section summarizes the indicators of a successful implementation.

Manual Build Success Indicators:

  • Build status: SUCCESS (blue ball icon)
  • Console output: "Finished: SUCCESS"
  • Workspace contains repository files

Webhook Automation Success Indicators:

  • GitHub webhook shows green checkmark
  • File changes trigger immediate builds
  • Build history shows sequential build numbers
  • No manual intervention required for new builds