Jenkins stores its configuration and build data primarily in the file system by default. The root directory (commonly called JENKINS_HOME
) contains all critical data:
/var/lib/jenkins/ (typical default on Ubuntu)
├── jobs/ # Job configurations and build artifacts
├── plugins/ # Installed plugins
├── users/ # User account information
├── workspace/ # Checked-out source code
├── config.xml # Global configuration
└── *.xml # Other system configurations
You can modify the storage location by setting the environment variable before starting Jenkins:
# In /etc/default/jenkins (Ubuntu/Debian):
JENKINS_HOME="/opt/jenkins_data"
# Or when running manually:
java -DJENKINS_HOME=/path/to/storage -jar jenkins.war
While Jenkins doesn't natively support RDBMS for core data storage, you have several options:
1. Using MySQL for Job Configuration (via ThinBackup Plugin)
The ThinBackup plugin can export configurations to MySQL:
# Configuration in Jenkins → Manage Jenkins → ThinBackup
Backup Storage Directory: /jenkins_backups
Database Configuration:
JDBC URL: jdbc:mysql://localhost:3306/jenkins_backup
Username: jenkins_user
Password: ********
Table Name: config_backups
2. Using Database for Build History (via SQL Plus Plugin)
The Database SQLPlus Plugin enables storing build results in databases:
// Pipeline example storing build results to MySQL
pipeline {
agent any
stages {
stage('Build') {
steps {
sh 'make'
}
post {
success {
sqlplus(
credentialsId: 'mysql-creds',
database: 'jenkins_stats',
script: """
INSERT INTO build_results
VALUES (${env.BUILD_NUMBER}, 'SUCCESS', NOW());
"""
)
}
}
}
}
}
For enterprise deployments, consider these architectural patterns:
1. NFS-mounted JENKINS_HOME for shared storage
2. Periodic rsync to backup servers
3. Containerized Jenkins with persistent volumes
4. Cloud storage backend (S3, GCS) for build artifacts
- File system storage provides best performance for Jenkins core operations
- Database integration works best for specific use cases (reporting, audit)
- Always maintain regular backups of JENKINS_HOME
- For HA setups, consider Jenkins Configuration as Code (JCasC) patterns
When you install Jenkins on Ubuntu or any other Linux distribution, it stores all configuration data, build histories, and job details in its home directory by default. The typical location is:
/var/lib/jenkins
This directory contains several important subdirectories:
jobs/
- Contains configuration and build records for each jobplugins/
- Stores installed plugins and their configurationsusers/
- User account information and preferencesworkspace/
- Working directories for jobs
While Jenkins primarily uses file-based storage, you can configure it to work with databases through plugins. MySQL integration is possible using the Database
plugin.
Here's how to set up MySQL as a backend for Jenkins:
- Install MySQL server and client packages:
- Create a Jenkins database and user:
- Install the Database plugin in Jenkins:
- Configure the database connection in Jenkins:
sudo apt-get install mysql-server mysql-client
CREATE DATABASE jenkins; CREATE USER 'jenkins'@'localhost' IDENTIFIED BY 'password'; GRANT ALL PRIVILEGES ON jenkins.* TO 'jenkins'@'localhost'; FLUSH PRIVILEGES;
Manage Jenkins → Manage Plugins → Available → Search "Database" → Install
Example configuration in config.xml
:
<database> <driver>com.mysql.jdbc.Driver</driver> <url>jdbc:mysql://localhost:3306/jenkins</url> <username>jenkins</username> <password>password</password> </database>
While database integration is possible, note that:
- Not all Jenkins data can be moved to a database (build artifacts remain on disk)
- Some plugins might not support database storage
- Performance impact should be tested for your specific workload
For better scalability, consider:
- Mounting the Jenkins home directory on network storage
- Using cloud storage solutions like AWS EFS
- Implementing regular backups of the
/var/lib/jenkins
directory