exp 44444
sudo wget -O /etc/apt/keyrings/jenkins-keyring.asc \ https://pkg.jenkins.io/debian-stable/jenkins.io-2023.key
echo "deb [signed-by=/etc/apt/keyrings/jenkins-keyring.asc]" \ https://pkg.jenkins.io/debian-stable binary/ | sudo tee \ /etc/apt/sources.list.d/jenkins.list > /dev/null
sudo systemctl start jenkins
sudo nano/var/lib/jenkins/config.xml
https://github.com/devops-ds/your-maven-project.git
**/target/surefire-reports/*.xml
pipeline {
agent any // Or specify a specific agent label
stages {
stage('Checkout') {
steps {
// Checkout code from your GitHub repository
git url: 'https://github.com/devops-ds/your-maven-project.git', branch: 'main' // Replace with your repo URL if different, adjust branch name if needed
// If your repository is private, you'll need to add credentials here, e.g.:
// git url: 'https://github.com/devops-ds/your-maven-project.git', branch: 'main', credentialsId: 'your-credential-id'
}
}
stage('Build') {
steps {
// Execute Maven build using the 'mvn' command with the full path
// To find the full path to your 'mvn' executable on Linux/macOS, open your terminal and run:
// which mvn
sh '/usr/bin/mvn clean package' // Replace with actual path
}
}
stage('Test') {
steps {
// Optionally, separate test execution if needed
// This step is often not strictly necessary if 'mvn clean package' already runs tests
// sh '/path/to/your/maven/bin/mvn test' // Replace with actual path
echo 'Tests are typically run during the Build stage with Maven.'
}
}
}
post {
always {
// Archive test reports
junit '**/target/surefire-reports/*.xml'
}
success {
echo 'Build and tests succeeded!'
}
failure {
echo 'Build or tests failed.'
}
// Add other post conditions like 'unstable', 'changed' as needed
}
}
Comments
Post a Comment