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
-
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).
-
Connect to Your EC2 Instance
ssh -i your-key.pem ec2-user@your-ec2-public-ip
2. Install Jenkins on EC2
-
Add Jenkins Repository
sudo wget -O /etc/yum.repos.d/jenkins.repo https://pkg.jenkins.io/redhat-stable/jenkins.repo -
Import Jenkins GPG Key
sudo rpm --import https://pkg.jenkins.io/redhat-stable/jenkins.io-2023.key -
Update Yum Packages
sudo yum update -y -
Install Jenkins
sudo yum install jenkins -y
3. Install Java 17 (OpenJDK)
-
Install Java 17
sudo yum install java-17-amazon-corretto -y -
Verify Java Installation
java -version
4. Configure Java Environment Variables
-
Set JAVA_HOME and PATH
echo "export JAVA_HOME=$(dirname $(dirname $(readlink $(readlink $(which java)))))" | sudo tee -a /etc/profileecho "export PATH=$PATH:$JAVA_HOME/bin" | sudo tee -a /etc/profilesource /etc/profile -
Verify JAVA_HOME
echo $JAVA_HOME
5. Start Jenkins
-
Start Jenkins Service
sudo systemctl start jenkins -
Enable Jenkins at Boot
sudo systemctl enable jenkins -
Check Jenkins Status
sudo systemctl status jenkins
6. Adjust Security Group or Firewall Settings
-
Allow Jenkins Port (8080)
Open port 8080 in your security group settings in AWS:
sudo firewall-cmd --permanent --zone=public --add-port=8080/tcpsudo firewall-cmd --reload
7. Access Jenkins and Complete Setup
-
Access Jenkins
Open a browser and navigate to:
http://your-ec2-public-ip:8080 -
Unlock Jenkins
sudo cat /var/lib/jenkins/secrets/initialAdminPassword -
Install Suggested Plugins
Choose "Install suggested plugins" for a quick setup.
-
Create Admin User
Follow prompts to create an admin account.
8. Install and Configure Maven
-
Download Maven
wget https://dlcdn.apache.org/maven/maven-3/3.9.9/binaries/apache-maven-3.9.9-bin.tar.gz -
Extract Maven
sudo tar -xvzf apache-maven-3.9.9-bin.tar.gz -C /opt/ -
Rename Maven Folder
sudo mv /opt/apache-maven-3.9.9 /opt/maven -
Set Maven Environment Variables
echo "export M2_HOME=/opt/maven" | sudo tee -a /etc/profileecho "export M2=$M2_HOME/bin" | sudo tee -a /etc/profileecho "export PATH=$PATH:$M2" | sudo tee -a /etc/profilesource /etc/profile -
Verify Maven Installation
mvn -version
9. Install Git
-
Install Git
sudo yum install git -y -
Verify Git Installation
git --version
10. Configure Jenkins for Java, Maven, and Git
-
Open Jenkins Dashboard
Navigate to Jenkins home and log in.
-
Navigate to Jenkins Configuration
Go to Manage Jenkins from the sidebar.
-
Access Global Tool Configuration
Click on Manage Jenkins → Global Tool Configuration.
-
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).
-
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).
-
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
-
Create a New Pipeline Project
Go to the Jenkins Dashboard, click New Item, name it (e.g., MyFirstPipeline), and select Freestyle Project.
-
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). -
Define Build Steps Using the "Build" Section
Add Build Steps:
- Invoke top-level Maven targets: Set the goal to
clean install. - Execute shell: Use commands like:
mvn clean compile - Invoke top-level Maven targets: Set the goal to
-
Configure Post-Build Actions
In the Post-build Actions section, add options like Archive the artifacts or Email Notification.
-
Save and Build the Project
Click Save, then go to the project’s main page and click Build Now to trigger the build.
-
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
Post a Comment