CI/CD Platform

    Self-Hosted Jenkins CI/CD

    Deploy Jenkins, the leading open-source automation server, on RamNode VPS. Build, test, and deploy your applications with powerful CI/CD pipelines.

    Ubuntu 22.04/24.04 LTS
    OpenJDK 17+
    ⏱️ 20-30 minutes

    Why Jenkins?

    Jenkins is the leading open-source automation server used for continuous integration and continuous delivery (CI/CD). It provides hundreds of plugins to support building, deploying, and automating any project.

    Extensive plugin ecosystem (1800+)
    Pipeline as Code with Jenkinsfile
    Distributed builds with agents
    Blue Ocean modern UI
    Docker and Kubernetes integration
    Enterprise-grade security

    System Requirements

    ComponentRequirement
    VPS PlanMinimum 2GB RAM (4GB+ recommended for production)
    Operating SystemUbuntu 22.04/24.04 LTS or Debian 12
    Storage20GB+ SSD (varies based on build artifacts)
    JavaOpenJDK 17 or 21 LTS

    Installation

    Step 1: Update System Packages

    Start by updating your VPS to ensure all packages are current:

    Update System
    sudo apt update && sudo apt upgrade -y

    Step 2: Install Java

    Jenkins requires Java to run. Install OpenJDK 17:

    Install Java
    sudo apt install openjdk-17-jdk -y
    
    # Verify installation
    java -version

    Step 3: Add Jenkins Repository

    Add the official Jenkins repository for the latest stable release:

    Add Jenkins Repository
    # Import Jenkins GPG key
    sudo wget -O /usr/share/keyrings/jenkins-keyring.asc \
      https://pkg.jenkins.io/debian-stable/jenkins.io-2023.key
    
    # Add repository
    echo "deb [signed-by=/usr/share/keyrings/jenkins-keyring.asc]" \
      "https://pkg.jenkins.io/debian-stable binary/" | \
      sudo tee /etc/apt/sources.list.d/jenkins.list > /dev/null

    Step 4: Install Jenkins

    Update the package index and install Jenkins:

    Install Jenkins
    sudo apt update
    sudo apt install jenkins -y

    Step 5: Start and Enable Jenkins

    Enable Jenkins to start on boot and start the service:

    Start Jenkins
    sudo systemctl enable jenkins
    sudo systemctl start jenkins
    
    # Check status
    sudo systemctl status jenkins

    Firewall Configuration

    Configure UFW to allow Jenkins traffic on port 8080:

    Configure UFW
    sudo ufw allow 8080/tcp
    sudo ufw allow OpenSSH
    sudo ufw enable
    
    # Verify rules
    sudo ufw status

    Initial Setup

    Access Jenkins Web Interface

    Open your browser and navigate to http://YOUR_VPS_IP:8080. You will see the unlock screen.

    Retrieve Initial Admin Password

    Get the initial administrator password:

    Get Admin Password
    sudo cat /var/lib/jenkins/secrets/initialAdminPassword

    Copy this password and paste it into the web interface to unlock Jenkins.

    Complete Setup Wizard

    1. Select "Install suggested plugins" for a standard setup
    2. Create your admin user account with a strong password
    3. Configure the Jenkins URL (use your VPS IP or domain)
    4. Click "Start using Jenkins" to complete setup

    Security Hardening

    Securing your Jenkins installation is critical for production environments. Follow these best practices:

    Configure Reverse Proxy with Nginx

    Set up Nginx as a reverse proxy to enable HTTPS and hide Jenkins behind port 443:

    Install Nginx
    sudo apt install nginx -y

    Create the Nginx configuration:

    /etc/nginx/sites-available/jenkins
    upstream jenkins {
        keepalive 32;
        server 127.0.0.1:8080;
    }
    
    server {
        listen 80;
        server_name jenkins.yourdomain.com;
    
        location / {
            proxy_pass http://jenkins;
            proxy_http_version 1.1;
            proxy_set_header Host $host;
            proxy_set_header X-Real-IP $remote_addr;
            proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
            proxy_set_header X-Forwarded-Proto $scheme;
            proxy_connect_timeout 150;
            proxy_send_timeout 100;
            proxy_read_timeout 100;
        }
    }

    Enable the site and restart Nginx:

    Enable Site
    sudo ln -s /etc/nginx/sites-available/jenkins /etc/nginx/sites-enabled/
    sudo nginx -t
    sudo systemctl restart nginx

    Enable SSL with Let's Encrypt

    Secure your Jenkins instance with a free SSL certificate:

    Install Certbot and Get SSL
    sudo apt install certbot python3-certbot-nginx -y
    sudo certbot --nginx -d jenkins.yourdomain.com

    Additional Security Measures

    • Enable CSRF Protection: Manage Jenkins → Security → Enable CSRF Protection
    • Configure Authentication: Use Jenkins' built-in user database or integrate with LDAP/Active Directory
    • Matrix-based Security: Enable fine-grained permissions for different user roles
    • Disable CLI over Remoting: Manage Jenkins → Security → Disable CLI over Remoting
    • Regular Updates: Keep Jenkins and plugins updated through the web interface

    Essential Plugins

    Install these recommended plugins via Manage Jenkins → Plugins → Available plugins:

    PluginPurpose
    GitGit repository integration
    PipelineJenkinsfile-based CI/CD pipelines
    Blue OceanModern visual pipeline editor and UI
    Docker PipelineBuild and push Docker images
    Credentials BindingSecure credential management in pipelines
    GitHub IntegrationWebhooks and PR status updates
    Slack NotificationBuild notifications to Slack channels

    Performance Optimization

    JVM Memory Settings

    Optimize Jenkins memory usage by editing the systemd override:

    Edit Systemd Override
    sudo systemctl edit jenkins

    Add these settings (adjust values based on your VPS RAM):

    JVM Settings
    [Service]
    Environment="JAVA_OPTS=-Xmx2g -Xms1g -XX:+UseG1GC"
    Environment="JENKINS_OPTS=--httpPort=8080"

    Reload and restart Jenkins:

    Restart Jenkins
    sudo systemctl daemon-reload
    sudo systemctl restart jenkins

    Build Executor Configuration

    Navigate to Manage Jenkins → System → # of executors. Set the number of executors based on your VPS CPU cores:

    • I/O-bound builds: 2× the number of CPU cores
    • CPU-intensive builds: 1× the number of CPU cores

    Backup Strategy

    Implement regular backups of your Jenkins configuration and jobs:

    jenkins-backup.sh
    #!/bin/bash
    # jenkins-backup.sh
    
    BACKUP_DIR="/opt/backups/jenkins"
    JENKINS_HOME="/var/lib/jenkins"
    DATE=$(date +%Y%m%d_%H%M%S)
    
    mkdir -p $BACKUP_DIR
    
    # Backup configuration, jobs, and credentials
    tar -czf $BACKUP_DIR/jenkins-backup-$DATE.tar.gz \
      $JENKINS_HOME/config.xml \
      $JENKINS_HOME/jobs \
      $JENKINS_HOME/users \
      $JENKINS_HOME/secrets \
      $JENKINS_HOME/credentials.xml \
      $JENKINS_HOME/plugins
    
    # Keep last 7 backups
    ls -t $BACKUP_DIR/jenkins-backup-*.tar.gz | tail -n +8 | xargs rm -f

    Schedule the backup script with cron:

    Schedule Backup
    sudo crontab -e
    
    # Add this line for daily backups at 2 AM
    0 2 * * * /opt/scripts/jenkins-backup.sh

    Troubleshooting

    Jenkins fails to start

    Check the system logs for errors:

    Check Logs
    sudo journalctl -u jenkins -f
    sudo cat /var/log/jenkins/jenkins.log

    Out of memory errors

    Increase JVM heap size in the systemd override (see Performance Optimization section) or consider upgrading your RamNode VPS plan.

    Permission denied errors

    Ensure the jenkins user has correct permissions:

    Fix Permissions
    sudo chown -R jenkins:jenkins /var/lib/jenkins

    Next Steps

    • Create your first Pipeline job using a Jenkinsfile
    • Configure webhook integrations with your Git repository
    • Set up build agents for distributed builds
    • Explore Jenkins Shared Libraries for reusable pipeline code
    • Monitor Jenkins performance with the Monitoring plugin

    Deployment Complete!

    Your Jenkins CI/CD server is now ready. Access the web interface at your configured domain, install additional plugins, and start building your automation pipelines!

    Ready to automate your builds?

    Get started with a RamNode VPS and deploy Jenkins in minutes.