![]() |
Overview of Jenkins |
Jenkins is a widely used open-source automation server that plays a crucial role in software development by facilitating continuous integration (CI) and continuous delivery (CD). It allows developers to automate various stages of the software development lifecycle, including building, testing, and deploying applications.
Overview of Jenkins
Origin: Originally named Hudson, Jenkins was created by Kohsuke Kawaguchi in 2004 while he worked at Sun Microsystems. The project was renamed Jenkins in 2011 following a trademark dispute with Oracle, which had forked the original Hudson project.
Functionality: Jenkins automates the software delivery process, enabling organizations to accelerate development cycles. It integrates with numerous version control systems like Git, Bitbucket, and GitHub, and supports various build tools such as Maven and Gradle.
Extensibility: With over 1,800 plugins available, Jenkins can be customized to fit a wide range of workflows and tools. This extensive plugin ecosystem allows it to integrate seamlessly with other technologies used in CI/CD pipelines.
Key Features
Continuous Integration and Delivery: Jenkins automates the process of integrating code changes from multiple contributors into a shared repository, ensuring that new code is tested and deployed quickly and efficiently.
Pipeline as Code: With the introduction of the Pipeline plugin, users can define their build processes using a domain-specific language based on Groovy. This allows for more complex workflows and better version control of build configurations.
Monitoring and Reporting: Jenkins provides real-time feedback on build statuses and can generate reports for various testing frameworks. It also supports notifications via email or other channels to keep teams informed about build results.
Community and Support
Jenkins has a vibrant community that contributes to its ongoing development. CloudBees, a key player in the Jenkins ecosystem, actively supports the project by contributing code and resources. The Continuous Delivery Foundation (CDF), launched in 2019, aims to promote open-source projects related to continuous delivery, including Jenkins
Using Jenkins for continuous integration (CI) and continuous delivery (CD) offers numerous benefits that enhance the software development process. Here are the key advantages:
Benefits of Using Jenkins for CI/CD
Early Detection of Issues: Jenkins automates the integration of code changes into a shared repository, allowing teams to detect and resolve integration issues early in the development cycle. This leads to higher code quality and reduces the likelihood of release failures.
Faster Development Cycles: By automating repetitive tasks such as building, testing, and deployment, Jenkins significantly shortens development cycles. This enables developers to focus on writing code rather than manual processes, accelerating time-to-market for new features.
Short Feedback Loops: Jenkins provides immediate feedback on code changes through automated testing. Developers can quickly identify problems when tests fail, facilitating faster iterations and reducing the time spent debugging later in the process.
Extensibility and Customization: With over 1,800 plugins available, Jenkins can be tailored to meet specific project needs. This rich plugin ecosystem allows integration with various tools and technologies, enhancing its functionality and adaptability.
Distributed Builds: Jenkins supports distributed builds across multiple machines, which improves build efficiency and reduces overall build times. This feature is particularly beneficial for large projects with extensive testing requirements.
Robust Security Features: Jenkins offers strong security controls, including project-based matrix authorization and role-based access control. These features help manage user permissions effectively, ensuring that sensitive operations are restricted to authorized personnel only.
Cost-Effectiveness: As an open-source tool, Jenkins is free to use, making it an attractive option for organizations looking to implement CI/CD without incurring significant costs.
Community Support: The large and active Jenkins community provides extensive resources, documentation, and support. This makes it easier for users to find solutions to problems and share best practices.
In summary, Jenkins streamlines the CI/CD process by automating key tasks, improving collaboration among team members, and enabling faster delivery of high-quality software.
JENKINS INSTALLATION
sudo yum update –y
sudo wget -O /etc/yum.repos.d/jenkins.repo \
https://pkg.jenkins.io/redhat-stable/jenkins.repo
sudo rpm --import https://pkg.jenkins.io/redhat-stable/jenkins.io-2023.key
sudo yum upgrade
sudo yum install java-17-amazon-corretto -y
sudo yum install jenkins -y
sudo systemctl enable jenkins
sudo systemctl start jenkins
sudo systemctl status jenkins
JENKINS SETUP
Step 1: Configure System Settings
Go to Manage Jenkins > Configure System.
Set Up JDK:
Provide a name for the JDK installation.
Set the JAVA_HOME path (e.g., C:\Program Files\Java\jdk1.8.0_251) or ( /var/lib/java/java-17)
Configure Maven:
Provide a Maven name.
Set the MAVEN_HOME path (e.g., C:\apache-maven-3.6.3).
Optionally, configure global Maven options like:
Save your configuration.
Step 2: Install Necessary Plugins
Go to Manage Jenkins > Manage Plugins.
Under the Available tab, search for and install:
Git Plugin
Maven Integration Plugin
Restart Jenkins if prompted.
Step 3: Create a New Job
From the Jenkins dashboard, click on New Item.
Enter a name for your project and select Maven Project, then click OK.
In the job configuration page:
Description: Add a brief description of your project.
Source Code Management:
Select Git.
Enter your Git repository URL (e.g., https://github.com/your-repo.git).
Specify the branch you want to build (default is usually master).
Build Triggers: Choose how you want to trigger builds (e.g., "Poll SCM" or "Build when a change is pushed to GitHub").
Build Environment: Optionally configure any build environment settings as needed.
Build Section:
Set the path to your pom.xml file in the "Root POM" field.
In "Goals and options," enter clean install to compile and package your application.
Save your job configuration.
Step 4: Build the Job
From the job page, click on Build Now to start the build process.
Monitor the build progress in the Build History section.
Step 5: Verify Build Results
After completion, click on the build number in the Build History to view details.
Check console output for logs, errors, or success messages related to your Maven build.
Following these steps will successfully set up a Jenkins job that integrates with Git and uses Maven for building your projects.
To configure Jenkins to trigger a build automatically on every push to a GitHub repository, follow these detailed steps:
Step 1: Install Required Plugins
Open Jenkins Dashboard: Access your Jenkins instance in a web browser.
Manage Jenkins: Click on Manage Jenkins from the left sidebar.
Manage Plugins: Select Manage Plugins.
Available Tab: In the Available tab, search for and install the following plugins:
GitHub Plugin
GitHub Branch Source Plugin (if using multi-branch pipelines)
Step 2: Configure Jenkins for GitHub Integration
Configure System:
Go back to Manage Jenkins and select Configure System.
Scroll down to the GitHub Plugin Configuration section.
Click on the Advanced... button.
Check the box for Specify another hook url for GitHub configuration. This will generate a Hook URL that GitHub will use to send POST requests to Jenkins.
Copy Hook URL:
Copy the Hook URL provided in the textbox. You will need this in the next steps.
Step 3: Set Up Webhook in GitHub Repository
Open Your GitHub Repository:
Navigate to your repository on GitHub.
Access Settings:
Click on the Settings tab in the repository menu.
Add Webhook:
In the left sidebar, click on Webhooks.
on the Add webhook button.
Configure Webhook:
In the Payload URL, paste the Hook URL you copied from Jenkins.
Set the content type to application/json.
Under Which events would you like to trigger this webhook?, select:
Just the push event (this triggers builds only on code pushes).
Click on Add webhook to save your settings.
Step 4: Configure Your Jenkins Job
Create or Configure a Job:
From the Jenkins dashboard, either create a new job or configure an existing one by clicking on its name and then selecting Configure.
Build Triggers Section:
Scroll down to the Build Triggers section.
Check the option for GitHub hook trigger for GITScm polling (or simply "Build when a change is pushed to GitHub" depending on your plugin version).
Save Configuration:
Click on the Save button at the bottom of the configuration page.
Step 5: Test Your Configuration
Make a code change in your local repository and push it to GitHub.
Monitor Jenkins for an automatic build triggered by this push.
Distrubuted builds
Step 1: Configure Jenkins for Distributed Builds
Install Required Plugins:
Go to Manage Jenkins > Manage Plugins.
Under the Available tab, search for and install the following plugins:
SSH Agent Plugin (for connecting to agents)
Set Up Nodes (Agents):
Go to Manage Jenkins > Manage Nodes and Clouds > New Node.
Enter a name for your agent, select "Permanent Agent," and click OK.
Configure Node Properties:
Set the number of executors (the number of concurrent builds).
Specify the remote root directory where builds will run on the agent.
Launch Method:
Choose "Launch agents via SSH."
Enter the agent's host (IP or DNS), credentials (SSH key), and any additional settings.
Save Configuration.
Step 2: Set Up a Job for Distributed Builds
Create a New Job:
From the Jenkins dashboard, click on New Item, enter a name, and select either a Freestyle project or Pipeline.
Configure Source Code Management:
Set up your Git repository under the Source Code Management section.
Build Triggers:
Configure triggers as needed (e.g., Poll SCM or Build when changes are pushed).
Build Environment:
If using a Freestyle project, check "Use secret text(s) or file(s)" if you need credentials for builds.
Build Steps:
Define your build steps (e.g., Maven, Gradle, shell commands).
Node Selection (for Distributed Builds):
In the job configuration, specify which node/agent to run this job on by selecting it from the "Restrict where this project can be run" field.
Step 3: Test Your Configuration
Trigger a build by clicking on the job name and then selecting Build Now.
Monitor the console output to ensure that builds are correctly distributed across configured nodes.
Post a Comment
0Comments