mirror of
https://github.com/Rainyy21/framework_note.git
synced 2026-10-11 00:30:29 -04:00
vault backup: 2026-06-03 02:13:53
This commit is contained in:
@@ -0,0 +1,106 @@
|
|||||||
|
---
|
||||||
|
title: "Jenkins: Basic Introduction and Project Usage Guide"
|
||||||
|
tags:
|
||||||
|
- jenkins
|
||||||
|
- devops
|
||||||
|
- cicd
|
||||||
|
- automation
|
||||||
|
- guide
|
||||||
|
created: 2026-06-03
|
||||||
|
---
|
||||||
|
|
||||||
|
# Jenkins: Basic Introduction and Project Usage Guide
|
||||||
|
|
||||||
|
Jenkins is the world's most popular open-source automation server. It helps developers automate the parts of software development related to building, testing, and deploying, facilitating **Continuous Integration (CI)** and **Continuous Delivery (CD)**.
|
||||||
|
|
||||||
|
## 1. Core Concepts
|
||||||
|
|
||||||
|
- **Controller (Master):** The central brain that handles the UI, job scheduling, and configuration.
|
||||||
|
- **Agent (Node):** Machines that do the actual work (running builds/tests). *Best Practice: Always run builds on agents, not the controller.*
|
||||||
|
- **Pipeline:** A user-defined model of a CD pipeline. It defines your entire build process, which typically includes stages for building, testing, and delivering.
|
||||||
|
- **Jenkinsfile:** A text file that contains the definition of a Jenkins Pipeline and is checked into source control (Git).
|
||||||
|
|
||||||
|
## 2. How to Use Jenkins for Your Project
|
||||||
|
|
||||||
|
The modern way to use Jenkins is **Pipeline as Code** using a `Jenkinsfile`.
|
||||||
|
|
||||||
|
### Step 1: Create a `Jenkinsfile`
|
||||||
|
In the root of your project repository, create a file named `Jenkinsfile` (no extension).
|
||||||
|
|
||||||
|
### Step 2: Define Your Pipeline
|
||||||
|
Here is a standard **Declarative Pipeline** template you can adapt:
|
||||||
|
|
||||||
|
```groovy
|
||||||
|
pipeline {
|
||||||
|
agent any // Tells Jenkins to run this pipeline on any available agent
|
||||||
|
|
||||||
|
environment {
|
||||||
|
// Define environment variables here
|
||||||
|
APP_NAME = "my-awesome-project"
|
||||||
|
}
|
||||||
|
|
||||||
|
stages {
|
||||||
|
stage('Checkout') {
|
||||||
|
steps {
|
||||||
|
// Jenkins automatically checks out code, but you can add custom logic
|
||||||
|
echo "Checking out code for ${APP_NAME}..."
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
stage('Build') {
|
||||||
|
steps {
|
||||||
|
echo 'Building...'
|
||||||
|
// Example for a Node.js project:
|
||||||
|
// sh 'npm install'
|
||||||
|
// Example for a Java/Maven project:
|
||||||
|
// sh './mvnw clean install'
|
||||||
|
sh 'echo "Insert build commands here"'
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
stage('Test') {
|
||||||
|
steps {
|
||||||
|
echo 'Testing...'
|
||||||
|
// sh 'npm test'
|
||||||
|
sh 'echo "Insert test commands here"'
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
stage('Deploy') {
|
||||||
|
steps {
|
||||||
|
echo 'Deploying...'
|
||||||
|
// sh './deploy.sh'
|
||||||
|
sh 'echo "Insert deployment commands here"'
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
post {
|
||||||
|
always {
|
||||||
|
echo 'Pipeline finished. Cleaning up...'
|
||||||
|
}
|
||||||
|
success {
|
||||||
|
echo 'Build Succeeded!'
|
||||||
|
}
|
||||||
|
failure {
|
||||||
|
echo 'Build Failed! Check logs.'
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
### Step 3: Configure Jenkins
|
||||||
|
1. Open your Jenkins Dashboard.
|
||||||
|
2. Click **New Item**, enter a name, and select **Pipeline**.
|
||||||
|
3. Under the **Pipeline** section, set **Definition** to "Pipeline script from SCM".
|
||||||
|
4. Select **Git** and provide your repository URL and credentials.
|
||||||
|
5. Ensure the **Script Path** is set to `Jenkinsfile`.
|
||||||
|
6. Click **Save** and then **Build Now**.
|
||||||
|
|
||||||
|
## 3. Best Practices for Your Project
|
||||||
|
|
||||||
|
1. **Keep it in Git:** Always store your `Jenkinsfile` in your repository. This allows versioning and easy recovery.
|
||||||
|
2. **Fail Fast:** Put unit tests and linting in the earliest stages. If they fail, the pipeline stops immediately, saving time.
|
||||||
|
3. **Use Credentials:** Never hardcode passwords or API keys. Use Jenkins' **Credentials Provider** and access them via the `credentials()` helper in your script.
|
||||||
|
4. **Isolated Environments:** Use **Docker** agents to ensure your build environment is consistent and doesn't conflict with other projects.
|
||||||
|
5. **Stages are Logical:** Use stages to group related steps. This makes the Jenkins UI much easier to read and debug.
|
||||||
@@ -0,0 +1,47 @@
|
|||||||
|
---
|
||||||
|
title: "Learn Jenkins! Complete Jenkins Course - Zero to Hero"
|
||||||
|
url: "https://www.youtube.com/watch?v=6YZvp2GwT0A"
|
||||||
|
tags:
|
||||||
|
- jenkins
|
||||||
|
- cicd
|
||||||
|
- devops
|
||||||
|
- automation
|
||||||
|
- docker
|
||||||
|
- summary
|
||||||
|
created: 2026-06-03
|
||||||
|
---
|
||||||
|
|
||||||
|
# Learn Jenkins! Complete Jenkins Course - Zero to Hero
|
||||||
|
|
||||||
|
This video is a comprehensive one-hour masterclass designed to take viewers from a basic understanding of Jenkins to a proficient level. It covers the fundamental concepts of CI/CD, infrastructure setup, and the practical implementation of automation pipelines.
|
||||||
|
|
||||||
|
## 1. Introduction to Jenkins and CI/CD Concepts
|
||||||
|
- **What is Jenkins?** Jenkins is an open-source automation server used to reliably build, test, and deploy software.
|
||||||
|
- **Role in DevOps:** The video emphasizes Jenkins' dominance in the CI/CD space despite newer alternatives, highlighting its extensive plugin ecosystem and flexibility.
|
||||||
|
|
||||||
|
## 2. Jenkins Infrastructure: Master and Agents
|
||||||
|
- **Architecture:** Explains the "Controller (Master) and Agent" model. The Controller manages the GUI, scheduling, and configuration, while Agents (Nodes) perform the actual heavy lifting of running builds.
|
||||||
|
- **Agent Types:** Discusses permanent agents versus cloud-based/dynamic agents (like Docker containers) that spin up on demand to save resources.
|
||||||
|
|
||||||
|
## 3. Installation and Setup
|
||||||
|
- **Docker-Based Setup:** Focuses on installing Jenkins using Docker to simplify environment management. Covers creating a custom Dockerfile with tools like Jenkins Plugin CLI and BlueOcean.
|
||||||
|
- **Web GUI Walkthrough:** A guided tour of the Jenkins dashboard, including plugin management, system settings, and build history.
|
||||||
|
|
||||||
|
## 4. Freestyle Jobs vs. Pipelines
|
||||||
|
- **Freestyle Jobs:** Demonstrates simple, UI-based automation tasks like running shell commands and Python scripts.
|
||||||
|
- **Pipelines:** Introduces the "Pipeline as Code" concept, the modern standard for Jenkins.
|
||||||
|
|
||||||
|
## 5. Advanced Automation and Pipelines
|
||||||
|
- **Declarative Pipelines (Groovy):** Instruction on writing Groovy-based scripts to define complex workflows.
|
||||||
|
- **Jenkinsfile:** Explains storing pipeline definitions in a `Jenkinsfile` within source control (like GitHub) for version-controlled CI/CD.
|
||||||
|
- **Triggers:** Shows how to configure automated builds via Webhooks or Polling.
|
||||||
|
|
||||||
|
## 6. Docker Integration and BlueOcean
|
||||||
|
- **Docker Cloud Agents:** Shows how to configure Jenkins to provision Docker containers as build agents for isolated environments.
|
||||||
|
- **BlueOcean:** Introduces the BlueOcean plugin for a modern, visual UI to design and diagnose Jenkins Pipelines.
|
||||||
|
|
||||||
|
## Key Topics Covered
|
||||||
|
- **Infrastructure:** Master/Agent architecture and Label-based job restriction.
|
||||||
|
- **Job Types:** Freestyle builds vs. Groovy-based Declarative Pipelines.
|
||||||
|
- **Environment:** Docker integration for Jenkins and its build agents.
|
||||||
|
- **Best Practices:** Using Jenkinsfiles and setting up automated triggers.
|
||||||
Reference in New Issue
Block a user