To set up a Continuous Integration (CI) pipeline using Jenkins that will:
On Ubuntu:
sudo apt update
sudo apt install openjdk-11-jdk -y
wget -q -O - https://pkg.jenkins.io/debian-stable/jenkins.io.key | sudo apt-key add -
sudo sh -c 'echo deb http://pkg.jenkins.io/debian-stable binary/ > /etc/apt/sources.list.d/jenkins.list'
sudo apt update
sudo apt install jenkins -y
sudo systemctl start jenkinshttp://your-server-ip:8080sudo cat /var/lib/jenkins/secrets/initialAdminPasswordGo to "Pipeline" section → Choose "Pipeline Script" and enter the following code:
pipeline {
    agent any
    environment {
        JAVA_HOME = "/usr/lib/jvm/java-11-openjdk-amd64"
        PATH = "$JAVA_HOME/bin:$PATH"
    }
    stages {
        stage('Clone Repository') {
            steps {
                git branch: 'main', url: 'https://github.com/your-username/your-java-repo.git'
            }
        }
        stage('Build Application') {
            steps {
                sh 'mvn clean package'
            }
        }
        stage('Run Tests') {
            steps {
                sh 'mvn test'
            }
        }
        stage('Archive Artifacts') {
            steps {
                archiveArtifacts artifacts: 'target/*.jar', fingerprint: true
            }
        }
    }
    post {
        success {
            echo 'Build was successful!'
        }
        failure {
            echo 'Build failed! Check the logs.'
        }
    }
}pipeline {
    agent any
    environment {
        PYTHON = "/usr/bin/python3"
    }
    stages {
        stage('Clone Repository') {
            steps {
                git branch: 'main', url: 'https://github.com/your-username/your-python-repo.git'
            }
        }
        stage('Setup Environment') {
            steps {
                sh 'python3 -m venv venv'
                sh 'source venv/bin/activate && pip install -r requirements.txt'
            }
        }
        stage('Run Tests') {
            steps {
                sh 'source venv/bin/activate && pytest tests/'
            }
        }
        stage('Linting') {
            steps {
                sh 'source venv/bin/activate && flake8 .'
            }
        }
    }
    post {
        success {
            echo 'Build was successful!'
        }
        failure {
            echo 'Build failed! Check the logs.'
        }
    }
}This basic CI pipeline automates the build process for a Java or Python application. It clones the repository, builds, tests, and archives artifacts while providing logs for debugging.