CI_CD - nighttourist/Batch-Management-System GitHub Wiki

Autor

Sakul Mia

Jenkins Overview

Jenkins is an open-source automation server that helps automate various parts of software development processes, such as building, testing, and deploying applications. It plays a crucial role in implementing Continuous Integration (CI) and Continuous Delivery (CD), enabling developers to integrate code changes frequently, run automated tests, and deploy applications consistently.

Key Features of Jenkins

  • Extensibility: Jenkins has a vast ecosystem of plugins to integrate with various tools and services (e.g., version control systems, build tools, testing frameworks).
  • Pipeline as Code: Jenkins supports defining build processes as code through its pipeline DSL, making CI/CD workflows easy to version and manage.
  • Distributed Builds: Jenkins can distribute build tasks across multiple machines, reducing build times and improving efficiency.
  • Easy Installation: Jenkins is easy to set up on different platforms and offers a user-friendly web interface.

Jenkins is widely adopted in the DevOps community and is considered a key tool for teams implementing CI/CD practices.


Jenkins Installation Guide

1. Download Jenkins

  • Visit the official Jenkins download page and select the appropriate installer for your operating system.

2. Install Java

Jenkins requires Java. If you don't have it installed, download it from the Oracle website. Ensure that the Java version is compatible with Jenkins (e.g., JDK 17).

  • During installation, point to the Java directory (e.g., jdk-17).
  • Choose a port (e.g., 8080 or 4040) for Jenkins to run on.

3. Set Up Jenkins

  • Open your browser and navigate to http://localhost:<port> (e.g., http://localhost:8080).
  • You will be prompted to enter an admin password. The password is stored in a file displayed on the setup page.
  • Navigate to the terminal and use the command shown to reveal the password. Paste this password in the Jenkins web UI.

4. Install Plugins

Once Jenkins is set up, install the necessary plugins based on your project needs. For example:

  • Node.js
  • npm
  • Git
  • GitHub
  • Slack (for notifications)

Configuring a Jenkins Job

1. Source Code Management (SCM)

If your code is hosted on a version control system (e.g., Git), configure the repository under the Source Code Management section. Provide your repository URL and credentials.

2. Build Triggers

Set up build triggers to define when Jenkins should initiate a build. You can configure triggers for:

  • Manual Build: Trigger builds manually.
  • Scheduled Builds: Use a cron-like syntax for periodic builds.
  • Git Webhooks: Trigger builds automatically when a commit is pushed to your repository.

3. Build Steps

Define the actual build process under the Build Steps section. You can:

  • Run shell commands or scripts.
  • Use build tools like Maven, Gradle, or npm to manage dependencies and run builds.

4. Post-Build Actions

Configure post-build actions, such as sending notifications to Slack, or publishing reports for tests or code coverage.


Running the Jenkins Job

Once your job is configured:

  1. Click Save to store your job settings.
  2. Go to the Jenkins dashboard and click Build Now to trigger a build manually.
  3. You can monitor the build progress in the Build History section.

Viewing Build Results

  • Console Output: View logs generated during the build under the console output section.
  • Reports: If you've set up test or code coverage reports, they will appear here as well.

Monitor and Manage Builds

  • Dashboard: Jenkins provides a central dashboard where you can view all jobs, their statuses, and trends over time.
  • Notifications: Configure notifications to send alerts after each build, either on success or failure. You can use tools like Slack or email for this.

Summary Workflow

  1. Install Jenkins
  2. Create Job
  3. Configure SCM & Build Steps
  4. Run Builds
  5. Monitor Results
⚠️ **GitHub.com Fallback** ⚠️