pipeline { agent any environment { // Define environment variables PROJECT_DIR = 'your_project_directory' } stages { stage('Build') { steps { echo 'Building the project...' // You can add your build tool commands here (e.g., Maven, Gradle, npm) sh 'echo "Building project in ${PROJECT_DIR}"' } } stage('Test') { steps { echo 'Running tests...' // Example: Run tests with a test framework (e.g., JUnit, Mocha) sh 'echo "Running tests in ${PROJECT_DIR}"' } } stage('Deploy') { steps { echo 'Deploying the application...' // Example: You can add your deployment steps (e.g., Docker push, SCP, Kubernetes apply) sh 'echo "Deploying project from ${PROJECT_DIR}"' } } } post { always { echo 'Cleaning up...' // Clean workspace to ensure no leftover files affect future builds cleanWs() } success { echo 'Pipeline finished successfully!' } failure { echo 'Pipeline failed.' } } }