Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Jenkinsfile (Declarative Pipeline) for Java / maven/ Spring Boot

I just came into new wave for Jenkinsfile, that is now allows to do it as Declarative Pipeline.

What should be standard Jenkinsfile for maven project, e.g. Spring Boot?

like image 891
Paul Verest Avatar asked Sep 06 '25 03:09

Paul Verest


1 Answers

This is my Jenkins File for my Maven Project. i.e., Spring Boot as per your requirement. Have a look.

node {
  try{
    stage 'checkout project'
    checkout scm

    stage 'check env'
    sh "mvn -v"
    sh "java -version"

    stage 'test'
    sh "mvn test"

    stage 'package'
    sh "mvn package"

    stage 'report'
    step([$class: 'JUnitResultArchiver', testResults: '**/target/surefire-reports/TEST-*.xml'])

    stage 'Artifact'
    step([$class: 'ArtifactArchiver', artifacts: '**/target/*.jar', fingerprint: true])

  }catch(e){
    throw e;
  }
}
like image 59
chaitanya bonka Avatar answered Sep 09 '25 21:09

chaitanya bonka