# Jenkins konfiguration

Nivå: beginner | Målgrupp: Programutvecklare och dev-ops personal | Förkunskaper: Erfarenhet av driftsättning av applikationer
https://www.ribomation.se/programmerings-kurser/jenkins-usage/

Lär dig allt om att installera, konfigurera och hantera Jenkins CI/CD server.

Denna omfattande kurs erbjuder en djupgående inblick i Jenkins CI-server, ett 
kraftfullt verktyg för bygg- och leveransautomatisering. Vi börjar med grunderna 
och avancerar sedan till mer komplexa begrepp, täcker allt från installation, 
konfiguration, till att skapa och hantera jobb.

En central del av vår undervisning fokuserar på integrationen av Jenkins med GIT 
och användningen av olika plugins för att optimera ditt arbetsflöde. I kursens
många praktiska övningar får du installera och konfigurera Jenkins server i
Amazon-molnet AWS och koppla ihop med GitHub.

Kursen är utformad för att passa både programmerare och dev-ops personal, och 
syftar till att hjälpa dig att implementera effektiva system för kontinuerlig 
integration och leverans. Följ med oss och lär dig hur du kan utnyttja kraften i 
Jenkins CI-servern i ditt eget arbete.

Glöm inte att kika på (_den kommande_) fortsättningskursen.
Du får då lära dig allt om Jenkins pipeline jobs, olika kategorier av pipeline jobs,
hur du enhetstestar pipeline kod. Vi börjar den kursen med att gå igenom språket
Groovy, som du behöver för att skriva pipeline kod. 

- Deep understanding of Jenkins CI server and its core functionality.
- Step-by-step guidance on installing Jenkins on various operating systems, including Linux and macOS.
- Techniques for configuring Jenkins for optimal performance, including plugin selection and user management.
- Setting up and managing jobs in Jenkins, and understanding different job types.
- Comprehensive knowledge of version control systems (VCS), focusing on Git integration with Jenkins.
- Usage of private Git repositories within Jenkins and handling credentials securely.
- Setting up and configuring various notifications and remote build agents for enhanced collaboration.
- Detailed understanding of different job types including building an application, deployment jobs, and multi-configuration jobs.
- Management skills for Jenkins with topics covering Jenkins CLI usage, backup & restore procedures, and configuration of authentication & authorization.
- Lessons about securing Jenkins server access through forwarding proxies and HTTPS.
- Overview of the Amazon AWS cloud platform as the course is designed with practical exercises performed in AWS.
- Necessary AWS concepts for Jenkins management and deployment such as EC2, IAM, S3 among others.
- Monitoring Jenkins performance using tools like Prometheus and Grafana for proactive issue resolution.
- Best practices for Jenkins administration and troubleshooting.
- Encourages participants to think creatively about how they can tailor Jenkins to meet their own or their organization's specific needs.

#### Jenkins Overview
- Kohsuke Kawaguchi - The inventor
- How Hudson became Jenkins
- What is Jenkins CI server?
- What is _continuous integration_?
- What is _continuous deployment_?
- Typical developer workflow
- Architecture
- Terminology
- Job structure

#### Case Studies
Some case studies, from the trenches.

### Brief About AWS
We will deploy and manage Jenkins in the Amazon AWS cloud, so this section will 
discuss just the absolute essentials of AWS in order to carry out the practical
exercises of the course.

#### Introduction to AWS
- What is _cloud computing_?
- What is _SaaS_?
- What is _XaaS_?
- Regions and zones
- Pricing model
- Virtual servers by EC2
- Firewall configuration by security groups
- SSH key pairs
- Authentication and authorization by IAM
- Static IP address allocation by EIP
- DNS using Route53
- Emails by SES
- AWS dev tools
- AWS CLI

#### How to launch an EC2 server
- More about EC2
- Steps to launch a server
- Choose region and zone
- Create SSH key-pair
- Create a security group (firewall rules)
- Choose an AMI
- Choose a machine instance type
- Configure instance details
- Configure a virtual hard-drive
- Attach the security group
- Attach the key-pair
- Connect to the server via the AWS browser console
- Connect to the server via SSH from the command-line
- Which username to login as (_depends on OS_)
- How to prevent losing the SSH connection
- How to get rid of the fingerprint SSH prompt
- Attaching a static IP
- Topics of AWS to be aware of, but not covered here

### Jenkins Fundamentals
How to install, configure and create jobs.

#### Installation
- Different installation forms
- Recommended hard-ware
- Steps to install on a Linux system (EC2)
- Preparation - installation of JDK
- Configure APT and install Jenkins
- How to recover, if something goes wrong
- How to control the jenkins server
- Using `systemctl`
- Installation on macOS
- Installation using Docker

#### Configuration
- Browse to the jenkins server
- How to unlock the server, to start the configuration
- Choose plugins
- Create an admin user
- Check its URL
- Overview of the configuration screens
- Light vs. dark mode
- Users
- View its home directory
- Some post-installation tasks
- How to change the TCP port, if needed
- How to reset/recover from lost admin password

#### Plugins
- What is a Jenkins plugin?
- Categories
- How to search for a plugin
- Check it activity and latest release date
- How to install a plugin
- Jenkins restart
- How to install a custom plugin

#### Simple Jobs
- Job list view
- Job types
- Single job view
- Job structure
- Build triggers
- Getting help
- Environment
- Steps and actions
- Post-build actions
- Output
- Workspace
- History
- Job folders

### GIT and Other VCS
In this section we discuss various topics related to fetching project files from
a VCS or GIT repo.

#### VCS Support in Jenkins
- What is a VCS (_Version Control System_)?
- VCS support in Jenkins
- List of available VCS plugins
- Understand the difference between the `Git` plugin and the `GitHub` (_or GitLab_) plugin

#### Fetching Files from GIT
- Git job configuration
- Branches
- Different triggers
- Setting up GitHub connections
- Manual builds
- Periodic builds
- Push triggered builds

#### Credentials
- What are credentials?
- How to use credentials in Jenkins
- Using the Credentials Manager
- Scopes
- Domain groups
- Types
- Secret text credentials
- GitHub access tokens

#### Cloning a private GIT repo via HTTPS
- How to access a private repo
- HTTPS vs. SSH
- GitHub clone using HTTPS
- Create an access token
- Create an HTTPS access credential
- Configure a build job with HTTPS clone

#### Cloning a private GIT repo via SSH
- GitHub clone using SSH
- Generate an SSH key-pair
- Register the public key with GitHub
- Create an SSH private key credential
- Configure a build job with SSH clone

### Notifications
In this section we discuss how to set up various notifications.

#### Notifications Overview
- What is a job notification?
- When can you perform a notify action?
- Notification types

#### Email Notifications
- What is email notification?
- Email notification plugins
- SMTP configuration
- Problems of email configuration
- SendGrid SMTP relay configuration
- Configure Jenkins to send emails
- Post build notification

#### CatLight Notifications
- What is CatLight?
- Installing CatLight
- Configure CatLight notification in Jenkins

#### Slack Notifications
- What is Slack notification?
- Slack notification steps
- Create a Slack app
- Configure bot token scopes
- Add Jenkins to a Slack channel
- Create a secret text credential for Slack
- Configure system Slack settings
- Using Slack notification in a build job

### Remote Agents
In this section we discuss why and how you set up remote build agents.
As a rule of thumb; never run build jobs on the main Jenkins controller,
always use build agents running on different server machines.

#### Build Agents Overview
- What are build agents?
- Why (always) use build agents?
- Static build agents
- Dynamic build agents
- Docker build agents

#### SSH Build Agents
- Using the _SSH Build Agent_ plugin
- Configure a SSH private key credential
- Launch a EC2 Linux instance
- Sign in and install Java JDK
- Configure agents on the main Jenkins server
- Agent labels
- Agent host key verification strategy
- Launch build jobs on an agent
- Launch build jobs based on labels
- Configuring a Ubuntu Linux agent (debian)
- Configuring an Alma Linux agent (redhat/centos)
- Launching a Linux build job

#### Windows Build Agents
- How a windows agent differ from a linux agent
- Launch a Windows EC2 instance
- How to log in to the Windows server (_N.B., has no SSH_)
- Using RDP
- Decrypting the Windows Administrator password
- Install Java JDK
- Configure the Jenkins controller to use the Windows agent
- Prepare the agent machine for Jenkins
- Download the `agent.jar` file
- Launch the agent directly
- Make the agent a Windows service
- Ensure the service runs as a non-privileged user
- Launching a Windows build job

#### Dynamic Build Agents
- How to utilize EC2 and create a dynamic number of agents
- Create an IAM account
- Create a key-pair
- Create a launch template
- Create an auto-scaling group
- Create a Jenkins credential with AWS access & secret keys
- Install the EC2-fleet Jenkins plugin
- Configure the EC2 agent fleet
- Launching a single job on the agent fleet
- Launching multiple jobs on the agent fleet

#### Docker Build Agents
- Setting up a Docker host, i.e., launch EC2 Linux machine and install Docker daemon
- What are the benefits of using Docker agents?
- Different ways of utilizing Docker in build jobs
- Prepare the Docker host for Jenkins
- Configure the Jenkins controller to use the Docker agent
- Launching a Docker build job

### Job Types
In this section we discuss various job types, such as building an application
vs. deploying an application, and more.

#### Parameterized Jobs
- What is a parameterized job?
- How is it defined?
- How is it working?
- Parameter types

#### Multi-Configuration Jobs
- What is a multi-configuration job?
- What is the purpose of such a job?
- How to create and configure a multi-configuration job
- Various multi-config axis and how to configure them

#### Application Build Jobs
- Commonly used build tools
- How to find and install build-tool plugins
- Tool configuration
- Let Jenkins download and install specific versions
- Sample Java Maven job
- Sample JavaScript Node.js NPM job
- Sample C++ CMake job

#### Artifact Storage Jobs
- What is an artifact
- Language specific artifact types
- What is an artifact storage server
- Installing and running Nexus as a Docker container
- Wait for a few minutes before browsing
- Obtain the temporary password
- Logging in and perform rudimentary configuration
- Install the _Nexus Artifact Uploader_ Jenkins plugin
- Configure the plugin
- Create a Maven freestyle job that uploads a JAR to Nexus

#### Deployment Jobs
- What do we mean by deployment?
- Accessing a service running on a remote server
- How to deploy a Java WAR to a Tomcat application server
- How to deploy a Node.js Express.js application to a server
- How to deploy a Vue.js PWA to a nginx server

#### PipeLine Jobs
This chapter just briefly touches on pipeline code, because we have a full
course devoted to writing Jenkins pipeline code.
- What is a pipeline job?
- What is Groovy?
- Inline pipeline code
- Remote `Jenkinsfile` code

### Administration Tasks
In this final section, we discuss various topics a Jenkins admin need to 
understand and perform.

#### Jenkins CLI
- What is the Jenkins CLI?
- What is its purpose?
- Installation and configuration of the CLI
- Typical CLI tasks

#### Backup & Restore
- What do we mean with make a backup of a Jenkins server?
- What do we mean with performing a restore
- The importance to backing up to remote storage
- Various backup & restore alternatives
- Using the ThinBackup plugin
- Performing a backup, using thin-backup
- Performing a restore, using thin-backup

#### Authentication & Authorization
- What is authentication?
- What is Authorization?
- Various alternatives for Jenkins
- Matrix authorization
- GitHub Organization users

#### Secure Access
- How can we secure the access to our Jenkins server?
- What is a forwarding proxy and why might it be useful?
- Installing nginx
- Configure nginx to be a forwarding proxy to a Jenkins server
- Brief about HTTPS
- How to configure HTTPS on nginx
- How to use an AWS load balancer with HTTPS access

#### Supervision of the Jenkins Server
- Why do we need to monitor Jenkins?
- What is Prometheus?
- What is Grafana?
- Installation of the tools
- Configuration of Jenkins to send metrics to Prometheus
- Viewing metric data via Grafana
