Skip to main content

Setting Up a Jenkins Pipeline Without Writing a Script for a GitHub Repository

Jenkins
Jenkins Pipeline Setup Guide

Jenkins Pipeline Setup Guide

This guide outlines the steps to set up a Jenkins pipeline using the graphical user interface (GUI) to connect to a GitHub repository, specifically https://github.com/SuneelG2021/spring3_project.git.

1. Launch an EC2 Instance

  1. Create an EC2 Instance

    Log in to the AWS Management Console and launch a new EC2 instance using Amazon Linux 2 or another preferred Linux distribution. Choose an instance type (e.g., t2.micro). Configure instance settings, ensuring that security groups allow traffic on ports 22 (SSH) and 8080 (Jenkins).

  2. Connect to Your EC2 Instance

    ssh -i your-key.pem ec2-user@your-ec2-public-ip

2. Install Jenkins on EC2

  1. Add Jenkins Repository

    sudo wget -O /etc/yum.repos.d/jenkins.repo https://pkg.jenkins.io/redhat-stable/jenkins.repo
  2. Import Jenkins GPG Key

    sudo rpm --import https://pkg.jenkins.io/redhat-stable/jenkins.io-2023.key
  3. Update Yum Packages

    sudo yum update -y
  4. Install Jenkins

    sudo yum install jenkins -y

3. Install Java 17 (OpenJDK)

  1. Install Java 17

    sudo yum install java-17-amazon-corretto -y
  2. Verify Java Installation

    java -version

4. Configure Java Environment Variables

  1. Set JAVA_HOME and PATH

    echo "export JAVA_HOME=$(dirname $(dirname $(readlink $(readlink $(which java)))))" | sudo tee -a /etc/profile
    echo "export PATH=$PATH:$JAVA_HOME/bin" | sudo tee -a /etc/profile
    source /etc/profile
  2. Verify JAVA_HOME

    echo $JAVA_HOME

5. Start Jenkins

  1. Start Jenkins Service

    sudo systemctl start jenkins
  2. Enable Jenkins at Boot

    sudo systemctl enable jenkins
  3. Check Jenkins Status

    sudo systemctl status jenkins

6. Adjust Security Group or Firewall Settings

  1. Allow Jenkins Port (8080)

    Open port 8080 in your security group settings in AWS:

    sudo firewall-cmd --permanent --zone=public --add-port=8080/tcp
    sudo firewall-cmd --reload

7. Access Jenkins and Complete Setup

  1. Access Jenkins

    Open a browser and navigate to:

    http://your-ec2-public-ip:8080
  2. Unlock Jenkins

    sudo cat /var/lib/jenkins/secrets/initialAdminPassword
  3. Install Suggested Plugins

    Choose "Install suggested plugins" for a quick setup.

  4. Create Admin User

    Follow prompts to create an admin account.

8. Install and Configure Maven

  1. Download Maven

    wget https://dlcdn.apache.org/maven/maven-3/3.9.9/binaries/apache-maven-3.9.9-bin.tar.gz
  2. Extract Maven

    sudo tar -xvzf apache-maven-3.9.9-bin.tar.gz -C /opt/
  3. Rename Maven Folder

    sudo mv /opt/apache-maven-3.9.9 /opt/maven
  4. Set Maven Environment Variables

    echo "export M2_HOME=/opt/maven" | sudo tee -a /etc/profile
    echo "export M2=$M2_HOME/bin" | sudo tee -a /etc/profile
    echo "export PATH=$PATH:$M2" | sudo tee -a /etc/profile
    source /etc/profile
  5. Verify Maven Installation

    mvn -version

9. Install Git

  1. Install Git

    sudo yum install git -y
  2. Verify Git Installation

    git --version

10. Configure Jenkins for Java, Maven, and Git

  1. Open Jenkins Dashboard

    Navigate to Jenkins home and log in.

  2. Navigate to Jenkins Configuration

    Go to Manage Jenkins from the sidebar.

  3. Access Global Tool Configuration

    Click on Manage Jenkins → Global Tool Configuration.

  4. Configure JDK

    Under the JDK section, click Add JDK, uncheck "Install automatically", and enter the name and path (e.g., /usr/lib/jvm/java-17-amazon-corretto).

  5. Configure Maven

    Under the Maven section, click Add Maven, enter a name (e.g., Maven 3.9.9), and provide the path (e.g., /opt/maven).

  6. Configure Git

    Under the Git section, ensure the Git executable path is set (e.g., /usr/bin/git).

11. Running a Jenkins Pipeline Without a Script

  1. Create a New Pipeline Project

    Go to the Jenkins Dashboard, click New Item, name it (e.g., MyFirstPipeline), and select Freestyle Project.

  2. Configure Source Code Management (SCM)

    In the Source Code Management section, select Git. Enter the repository URL: https://github.com/SuneelG2021/spring3_project.git. Specify the branch to build (e.g., */main).

  3. Define Build Steps Using the "Build" Section

    Add Build Steps:

    1. Invoke top-level Maven targets: Set the goal to clean install.
    2. Execute shell: Use commands like:
    3. mvn clean compile
  4. Configure Post-Build Actions

    In the Post-build Actions section, add options like Archive the artifacts or Email Notification.

  5. Save and Build the Project

    Click Save, then go to the project’s main page and click Build Now to trigger the build.

  6. Monitor and View Build Results

    Click the build number in the Build History to view Console Output for logs and check the build status.

Summary

This guide provides a comprehensive process to set up and run a Jenkins pipeline using the GUI, connected to the GitHub repository https://github.com/SuneelG2021/spring3_project.git. The configuration is completed entirely through the Jenkins interface, without the need for script writing.

Comments

Popular posts from this blog

A Complete CI/CD Pipeline

Complete CI/CD Pipeline Using GitHub, Jenkins, Maven, SonarQube, Nexus, and Docker A well-designed CI/CD pipeline plays a critical role in modern DevOps practices by automating software delivery, improving code quality, and reducing deployment risks. In this article, I will explain how I build an automated CI/CD pipeline using GitHub, Jenkins, Maven, SonarQube, Nexus Repository, Docker, and Docker Hub. Source Code Management with GitHub The CI/CD workflow begins with storing the application source code in GitHub. Developers regularly push code changes or create pull requests to collaborate on features and bug fixes. Whenever new code is pushed to the repository, GitHub triggers Jenkins automatically through a webhook. This integration helps start the CI/CD pipeline without manual intervention. Code Checkout Stage in Jenkins The first stage of the pipeline is the checkout process. Jenkins connects to the GitHub repository and pulls the latest version of the source code. ...

Terraform for AWS: Step-by-Step Infrastructure Automation That Actually Works

How I Use Terraform to Provision and Manage AWS Infrastructure Efficiently Infrastructure as Code (IaC) has become a critical part of modern cloud operations, and Terraform is one of the most popular tools for automating cloud infrastructure deployment. In this article, I'll share how I use Terraform to build and manage AWS resources such as Virtual Private Clouds (VPCs), EC2 instances, Application Load Balancers (ALBs), and Auto Scaling Groups. Building AWS Infrastructure with Terraform My infrastructure deployment process begins by defining all AWS resources as code. This approach ensures consistency, repeatability, and easier management across multiple environments. The first step is creating a secure network architecture using a VPC. Within the VPC, I configure public and private subnets, route tables, internet gateways, and other networking components required for application deployment. Once the networking layer is ready, I deploy EC2 instances inside private su...

Master Linux Administration for DevOps: Powerful Commands, Troubleshooting Tips & Best Practices

Linux administration is one of the most important skills for anyone working in DevOps. From application servers and CI/CD platforms to containers and cloud infrastructure, Linux-based systems are widely used in modern technology environments. In my day-to-day DevOps activities, I regularly work with Linux commands to manage files, monitor processes, troubleshoot services, investigate network problems, analyze logs, and resolve production issues. This guide covers essential Linux administration concepts and commands that are useful for DevOps engineers, along with practical examples of how they can be applied during everyday troubleshooting. 1. Understanding Linux File Permissions Linux uses a permission system to control access to files and directories. The three basic permissions are: Read (r) – Allows a user to view the contents of a file or directory. Write (w) – Allows modifications to a file or directory. Execute (x) – Allows a file to be executed or a director...