🛠️

Getting Started with Jenkins Automation

Sep 8, 2024

Comprehensive Guide to Getting Started with Jenkins

Introduction

  • Overview of the guide to Jenkins
  • Includes theory and practical labs
  • Jenkins is a valuable DevOps skill with high earning potential ($150,000 - $250,000/year)
  • Capable of automating various tasks, including running scripts and playbooks
  • Video contents:
    • Setting up Jenkins server
    • Managing Jenkins agents
    • Creating a declarative Jenkins pipeline with Groovy

What is Jenkins?

  • Jenkins is an automation platform for building, testing, and deploying software using pipelines.
  • Can automate any task, not just code pipelines.
  • Provides a web GUI for creating jobs and customizing functionalities.
  • Features include source control management, build triggers, and build management.

Jenkins Infrastructure

  • Master Server: Controls pipelines and schedules builds to agents.
  • Agents: Run builds in their workspace.
  • Workflow Example:
    1. Developer commits code to a git repository.
    2. Jenkins master triggers the pipeline and distributes the build to an agent.
    3. Agent runs build commands (Linux commands).

Types of Jenkins Agents

  1. Permanent Node Agents: Standalone Linux/Windows servers configured to run Jenkins jobs (Java and SSH required).
  2. Cloud Agents: More commonly used in environments; examples include Docker, Kubernetes, and AWS.
    • Can dynamically spin up agents based on templates.
    • Lab demonstration of setting up Docker as a cloud agent.

Build Jobs in Jenkins

1. Freestyle Build Projects

  • Simplest way to start with Jenkins.
  • Shell scripts triggered by events (e.g. code commits).
  • Managed through UI and plugins.

2. Pipelines

  • Defined using Jenkins files written in Groovy syntax.
  • Divided into stages (e.g., clone, build, test, package, deploy).

Jenkins Installation

  • Installation options:
    • Directly onto the OS or in a container (Docker recommended).
  • Installation steps:
    1. Build the Docker image.
    2. Create a network for Jenkins.
    3. Launch the container.
  • Example commands provided for various OS.

Getting Started with Jenkins UI

  • Key UI Features:
    • Breadcrumbs for navigation
    • New Item for creating projects/pipelines
    • Build History for job history
    • Manage Jenkins for configurations and plugins

Key Management Areas in Jenkins

  • Configure System: Global settings
  • Manage Plugins: Critical for updating and maintaining plugins.
  • Manage Nodes and Clouds: Setting up agents (permanent/cloud).
  • Security Settings: Configuring global security, managing users, and credentials.

Creating Your First Project

  • Steps to create a Freestyle Project:
    1. Name your project (avoid spaces).
    2. Configure Source Control Management (Git repository).
    3. Setup Build Triggers (webhooks or polling SCM).
    4. Define Build Steps (execute shell commands).
  • Example of a "Hello World" build.

Using Environment Variables

  • Utilize Jenkins environment variables (e.g. build ID, build URL) in builds.

Troubleshooting and File System

  • Access Jenkins file system via Docker exec for troubleshooting.
  • Important folders: workspace, plugins, logs, configuration files.

Advanced Topics

Setting Up Agents & Pipelines

  • Setting up permanent and cloud agents through Manage Jenkins.
  • Overview of configuring Docker agents for pipelines.

Creating a Pipeline

  • Steps to create a pipeline using Jenkins file:
    1. Define pipeline script or use Jenkins file from SCM.
    2. Create stages (build, test, deliver).
    3. Implement build commands and test commands.

Blue Ocean Plugin

  • Introduction to Blue Ocean for enhanced Jenkins interface.
  • Supports multi-stage pipelines and better visualizations.

Conclusion

  • Summary of key skills learned:
    • Installing Jenkins master and agents
    • Managing freestyle projects
    • Building pipelines using Groovy
  • Encouragement to ask questions and subscribe for more content.