Jenkins Interface and Jobs
Web interface
Main dashboard
┌─────────────────────────────────────────────────────────────┐
│ Jenkins [Search] [Admin ▼] │
├─────────────────────────────────────────────────────────────┤
│ │
│ ┌──────────────┐ ┌─────────────────────────────────────┐ │
│ │ New Item │ │ Build Queue │ │
│ │ People │ │ (empty) │ │
│ │ Build History│ ├─────────────────────────────────────┤ │
│ │ Manage │ │ Build Executor Status │ │
│ │ My Views │ │ ● master (idle) │ │
│ │ Credentials │ │ ● agent-1 (building #42) │ │
│ └──────────────┘ └─────────────────────────────────────┘ │
│ │
│ All Jobs │
│ ┌─────────────────────────────────────────────────────┐ │
│ │ Name │ Status │ Last │ Duration │ Weather │ │
│ │──────────────┼────────┼──────┼──────────┼───────────│ │
│ │ ☀️ my-app │ ✓ │ #45 │ 2m 30s │ ☀️ │ │
│ │ ⛈️ api-tests │ ✗ │ #12 │ 5m 15s │ ⛈️ │ │
│ │ 🌤️ deploy │ ● │ #8 │ 1m 45s │ 🌤️ │ │
│ └─────────────────────────────────────────────────────┘ │
└─────────────────────────────────────────────────────────────┘
Status indicators
| Icon | Meaning |
|---|---|
| 🔵 ✓ | Successful build |
| 🔴 ✗ | Failed build |
| 🟡 ⚠ | Unstable build (tests failed) |
| ⚪ | Never built |
| 🔄 | Build in progress |
| ⏸️ | Build disabled |
Weather
The weather indicates the trend of recent builds:
| Weather | Meaning |
|---|---|
| ☀️ | 80%+ success |
| 🌤️ | 60-80% success |
| ⛅ | 40-60% success |
| 🌧️ | 20-40% success |
| ⛈️ | 0-20% success |
Job types
Freestyle Project
A classic job configured through the interface.
Use case: Simple scripts, one-off tasks.
Pipeline
A job defined in Groovy code.
Use case: Complex CI/CD, Pipeline as Code.
Multibranch Pipeline
An automatic pipeline per Git branch.
Use case: Projects with multiple active branches.
Folder
Logical organization of jobs.
my-organization/
├── frontend/
│ ├── web-app
│ └── mobile-app
├── backend/
│ ├── api
│ └── workers
└── infrastructure/
├── terraform
└── kubernetes
Create a Freestyle Job
Step 1: New job
- Click "New Item"
- Enter the name:
my-first-job - Select "Freestyle project"
- Click "OK"
Step 2: General configuration
General
├── Description: Mon premier job Jenkins
├── Discard old builds: ✓
│ └── Max # of builds to keep: 10
├── GitHub project: https://github.com/user/repo
└── This project is parameterized: ✓
Step 3: Source Code Management
Source Code Management
├── Git
│ ├── Repository URL: https://github.com/user/repo.git
│ ├── Credentials: github-credentials
│ └── Branches to build: */main
Step 4: Build Triggers
Build Triggers
├── Build periodically: H/15 * * * *
├── Poll SCM: H/5 * * * *
├── GitHub hook trigger for GITScm polling: ✓
└── Build after other projects: upstream-job
Cron syntax
┌───────────── minute (0-59)
│ ┌───────────── hour (0-23)
│ │ ┌───────────── day of month (1-31)
│ │ │ ┌───────────── month (1-12)
│ │ │ │ ┌───────────── day of week (0-7)
│ │ │ │ │
* * * * *
Exemples:
H * * * * # Toutes les heures (minute aléatoire)
H/15 * * * * # Toutes les 15 minutes
H 0 * * * # Chaque jour à minuit
H 0 * * 1-5 # Chaque jour de semaine à minuit
Step 5: Build Environment
Build Environment
├── Delete workspace before build starts: ✓
├── Add timestamps to Console Output: ✓
├── Use secret text(s) or file(s): ✓
│ └── Secret text: DOCKER_PASSWORD
└── Inject environment variables: ✓
└── Properties Content: ENV=production
Step 6: Build Steps
Build Steps
├── Execute shell:
│ #!/bin/bash
│ echo "Building version: $BUILD_NUMBER"
│ npm install
│ npm run build
│ npm test
│
├── Invoke Gradle script:
│ └── Tasks: clean build test
│
└── Execute Windows batch command:
└── msbuild /p:Configuration=Release
Step 7: Post-build Actions
Post-build Actions
├── Archive the artifacts: target/*.jar
├── Publish JUnit test result report: target/test-reports/*.xml
├── E-mail Notification: [email protected]
├── Build other projects: deploy-job
└── Slack Notifications: ✓
Build parameters
Parameter types
// String Parameter
properties([
parameters([
string(
name: 'BRANCH',
defaultValue: 'main',
description: 'Branche à construire'
),
// Choice Parameter
choice(
name: 'ENVIRONMENT',
choices: ['dev', 'staging', 'prod'],
description: 'Environnement cible'
),
// Boolean Parameter
booleanParam(
name: 'SKIP_TESTS',
defaultValue: false,
description: 'Passer les tests'
),
// Password Parameter
password(
name: 'DEPLOY_TOKEN',
description: 'Token de déploiement'
),
// File Parameter
file(
name: 'CONFIG_FILE',
description: 'Fichier de configuration'
)
])
])
Using parameters
# Dans un script shell
echo "Deploying to: ${ENVIRONMENT}"
echo "Branch: ${BRANCH}"
if [ "${SKIP_TESTS}" = "true" ]; then
echo "Skipping tests..."
else
npm test
fi
Environment variables
Predefined variables
| Variable | Description |
|---|---|
BUILD_NUMBER | Build number |
BUILD_ID | Unique build ID |
BUILD_URL | Build URL |
JOB_NAME | Job name |
WORKSPACE | Workspace path |
JENKINS_URL | Jenkins URL |
GIT_COMMIT | Commit hash |
GIT_BRANCH | Git branch |
NODE_NAME | Agent name |
EXECUTOR_NUMBER | Executor number |
Accessing the variables
# Shell
echo "Build #${BUILD_NUMBER} on ${NODE_NAME}"
echo "Commit: ${GIT_COMMIT}"
# Groovy
echo "Build: ${env.BUILD_NUMBER}"
echo "Job: ${env.JOB_NAME}"
Console Output
Reading the logs
Started by user admin
Running as SYSTEM
Building in workspace /var/jenkins_home/workspace/my-job
[my-job] $ /bin/bash -xe /tmp/jenkins123.sh
+ echo Building version: 42
Building version: 42
+ npm install
...
+ npm test
All tests passed!
Finished: SUCCESS
Filtering the logs
// Masquer les secrets
wrap([$class: 'MaskPasswordsBuildWrapper']) {
sh 'echo "Password: $SECRET_PASSWORD"'
}
Workspace management
Structure
/var/jenkins_home/workspace/
├── my-job/
│ ├── src/
│ ├── package.json
│ └── node_modules/
├── my-job@2/ # Builds parallèles
└── my-job@tmp/ # Fichiers temporaires
Cleaning the workspace
// Dans un pipeline
cleanWs()
// Ou en Freestyle
// ✓ Delete workspace before build starts
Summary
| Concept | Description |
|---|---|
| Dashboard | Overview of jobs |
| Freestyle | Job configured via UI |
| Pipeline | Job defined in code |
| Multibranch | Pipeline per branch |
| Parameters | User inputs |
| Workspace | Working directory |