Skip to main content

Jenkins Plugins


Introduction

Plugins extend Jenkins' capabilities. There are more than 1800 plugins available.


Managing plugins

Via the interface

  1. Manage Jenkins > Manage Plugins
  2. Tabs:
    • Updates: Available updates
    • Available: Plugins to install
    • Installed: Installed plugins
    • Advanced: Manual upload

Via CLI

# Lister les plugins installés
java -jar jenkins-cli.jar -s http://localhost:8080/ list-plugins

# Installer un plugin
java -jar jenkins-cli.jar -s http://localhost:8080/ install-plugin git

# Installer plusieurs plugins
java -jar jenkins-cli.jar -s http://localhost:8080/ install-plugin \
git docker-workflow kubernetes blueocean

# Redémarrer Jenkins
java -jar jenkins-cli.jar -s http://localhost:8080/ safe-restart

Via Docker

FROM jenkins/jenkins:lts-jdk17

# Copier la liste des plugins
COPY plugins.txt /usr/share/jenkins/ref/plugins.txt

# Installer les plugins
RUN jenkins-plugin-cli --plugin-file /usr/share/jenkins/ref/plugins.txt
# plugins.txt
git:latest
docker-workflow:latest
kubernetes:latest
blueocean:latest
configuration-as-code:latest
credentials-binding:latest
pipeline-stage-view:latest

Essential plugins by category

Source Control

PluginDescription
GitGit integration
GitHubWebhooks, status checks
GitLabGitLab integration
BitbucketBitbucket integration
// Exemple Git
pipeline {
agent any
stages {
stage('Checkout') {
steps {
git branch: 'main',
url: 'https://github.com/org/repo.git',
credentialsId: 'github-creds'
}
}
}
}

Build Tools

PluginDescription
Maven IntegrationMaven support
GradleGradle support
NodeJSNode.js/npm support
GoGo support
// NodeJS Plugin
pipeline {
agent any
tools {
nodejs 'Node-18'
}
stages {
stage('Build') {
steps {
sh 'npm ci'
sh 'npm run build'
}
}
}
}

Containers

PluginDescription
Docker PipelineBuild/push Docker images
DockerDocker agents
KubernetesDynamic K8s agents
// Docker Pipeline
pipeline {
agent any
stages {
stage('Build Image') {
steps {
script {
def image = docker.build("my-app:${BUILD_NUMBER}")
docker.withRegistry('https://registry.example.com', 'docker-creds') {
image.push()
image.push('latest')
}
}
}
}
}
}

Quality

PluginDescription
SonarQube ScannerCode analysis
Warnings Next GenerationAnalysis reports
JaCoCoCode coverage
JUnitTest results
// SonarQube
pipeline {
agent any
environment {
SONAR_TOKEN = credentials('sonar-token')
}
stages {
stage('SonarQube Analysis') {
steps {
withSonarQubeEnv('SonarQube') {
sh '''
sonar-scanner \
-Dsonar.projectKey=my-project \
-Dsonar.sources=src \
-Dsonar.login=${SONAR_TOKEN}
'''
}
}
}
stage('Quality Gate') {
steps {
timeout(time: 10, unit: 'MINUTES') {
waitForQualityGate abortPipeline: true
}
}
}
}
}

Notifications

PluginDescription
Slack NotificationSlack messages
Email ExtensionAdvanced emails
Microsoft TeamsTeams messages
// Slack
post {
success {
slackSend(
channel: '#builds',
color: 'good',
message: "✅ *${JOB_NAME}* #${BUILD_NUMBER} succeeded\n${BUILD_URL}"
)
}
failure {
slackSend(
channel: '#builds',
color: 'danger',
message: "❌ *${JOB_NAME}* #${BUILD_NUMBER} failed\n${BUILD_URL}"
)
}
}

// Email Extension
post {
failure {
emailext(
subject: "FAILED: ${JOB_NAME} #${BUILD_NUMBER}",
body: '''
<h2>Build Failed</h2>
<p>Job: ${JOB_NAME}</p>
<p>Build: ${BUILD_NUMBER}</p>
<p>URL: ${BUILD_URL}</p>
<p>Console: ${BUILD_URL}console</p>
''',
mimeType: 'text/html',
to: '[email protected]',
attachLog: true
)
}
}

Credentials

PluginDescription
Credentials BindingSecret injection
HashiCorp VaultVault secrets
AWS CredentialsAWS credentials
// Credentials Binding
pipeline {
agent any
stages {
stage('Deploy') {
steps {
withCredentials([
usernamePassword(
credentialsId: 'docker-hub',
usernameVariable: 'DOCKER_USER',
passwordVariable: 'DOCKER_PASS'
),
string(
credentialsId: 'api-key',
variable: 'API_KEY'
),
file(
credentialsId: 'kubeconfig',
variable: 'KUBECONFIG'
)
]) {
sh 'echo $DOCKER_PASS | docker login -u $DOCKER_USER --password-stdin'
sh 'kubectl --kubeconfig=$KUBECONFIG apply -f k8s/'
}
}
}
}
}

Pipeline

PluginDescription
PipelinePipeline support
Pipeline: Stage ViewStage visualization
Blue OceanModern interface
Pipeline Utility StepsUtilities

Blue Ocean

A modern interface for Jenkins.

Installation

# Via CLI
java -jar jenkins-cli.jar install-plugin blueocean

# Via plugins.txt
blueocean:latest

Features

  • Modern user interface
  • Visual pipeline editor
  • Branch visualization
  • GitHub/GitLab integration
  • Improved logs

Access

http://jenkins:8080/blue


Configuration as Code (JCasC)

Plugin

# plugins.txt
configuration-as-code:latest

Plugin configuration

# jenkins.yaml
jenkins:
systemMessage: "Jenkins configured with JCasC"

unclassified:
# SonarQube
sonarGlobalConfiguration:
buildWrapperEnabled: true
installations:
- name: "SonarQube"
serverUrl: "https://sonar.example.com"
credentialsId: "sonar-token"

# Slack
slackNotifier:
teamDomain: "mycompany"
tokenCredentialId: "slack-token"
room: "#jenkins"

# Git
gitSCM:
globalConfigName: "Jenkins"
globalConfigEmail: "[email protected]"

tool:
# NodeJS
nodejs:
installations:
- name: "Node-18"
properties:
- installSource:
installers:
- nodeJSInstaller:
id: "18.19.0"
npmPackagesRefreshHours: 72
- name: "Node-20"
properties:
- installSource:
installers:
- nodeJSInstaller:
id: "20.10.0"

# Maven
maven:
installations:
- name: "Maven-3.9"
properties:
- installSource:
installers:
- maven:
id: "3.9.6"

# Docker
dockerTool:
installations:
- name: "Docker"
properties:
- installSource:
installers:
- fromDocker:
version: "latest"

Kubernetes Plugin

Configuration

# jenkins.yaml
jenkins:
clouds:
- kubernetes:
name: "kubernetes"
serverUrl: "https://kubernetes.default"
namespace: "jenkins"
jenkinsUrl: "http://jenkins:8080"
jenkinsTunnel: "jenkins-agent:50000"
containerCap: 10
podLabels:
- key: "jenkins"
value: "agent"
templates:
- name: "default"
label: "kubernetes-agent"
nodeUsageMode: NORMAL
containers:
- name: "jnlp"
image: "jenkins/inbound-agent:latest"
workingDir: "/home/jenkins/agent"
resourceRequestCpu: "500m"
resourceRequestMemory: "512Mi"
volumes:
- hostPathVolume:
hostPath: "/var/run/docker.sock"
mountPath: "/var/run/docker.sock"

Usage

pipeline {
agent {
kubernetes {
yaml '''
apiVersion: v1
kind: Pod
metadata:
labels:
app: jenkins-agent
spec:
containers:
- name: maven
image: maven:3.8-openjdk-17
command: ['sleep', 'infinity']
volumeMounts:
- name: m2-cache
mountPath: /root/.m2
- name: docker
image: docker:24-dind
securityContext:
privileged: true
volumes:
- name: m2-cache
persistentVolumeClaim:
claimName: maven-cache
'''
}
}

stages {
stage('Build') {
steps {
container('maven') {
sh 'mvn clean package'
}
}
}
stage('Docker Build') {
steps {
container('docker') {
sh 'docker build -t my-app .'
}
}
}
}
}

Docker Plugin

Docker Pipeline

pipeline {
agent any

stages {
stage('Build in Docker') {
agent {
docker {
image 'node:18'
args '-v /tmp:/tmp'
}
}
steps {
sh 'npm ci && npm run build'
}
}

stage('Build Docker Image') {
steps {
script {
def app = docker.build("my-app:${BUILD_NUMBER}")

docker.withRegistry('https://registry.example.com', 'docker-creds') {
app.push()
app.push('latest')
}
}
}
}

stage('Test with Docker Compose') {
steps {
sh 'docker-compose -f docker-compose.test.yml up -d'
sh 'npm run test:e2e'
sh 'docker-compose -f docker-compose.test.yml down'
}
}
}
}

# plugins.txt - Installation minimale recommandée

# Core Pipeline
workflow-aggregator:latest
pipeline-stage-view:latest
pipeline-utility-steps:latest

# Source Control
git:latest
github:latest
github-branch-source:latest

# Build Tools
nodejs:latest
maven-plugin:latest

# Containers
docker-workflow:latest
kubernetes:latest

# Quality
sonar:latest
junit:latest
jacoco:latest
warnings-ng:latest

# Notifications
slack:latest
email-ext:latest

# Credentials
credentials-binding:latest

# Configuration
configuration-as-code:latest
job-dsl:latest

# UI
blueocean:latest

# Utilities
timestamper:latest
ansicolor:latest
rebuild:latest

← Jenkinsfile | Agents →