From dace389f0474532b63025da2eef942a722dfb82d Mon Sep 17 00:00:00 2001 From: devops Date: Mon, 15 Dec 2025 01:47:54 +0800 Subject: [PATCH] Added Jenkinsfile --- Jenkinsfile | 61 ++++++++++++++++++++++++----------------------------- 1 file changed, 27 insertions(+), 34 deletions(-) diff --git a/Jenkinsfile b/Jenkinsfile index a125b3b..407c29a 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -1,38 +1,31 @@ pipeline { - agent any - - tools { - // Install the Maven version configured as "M3" and add it to the path. - maven "M398" + agent any + stages { + stage('Echo Version') { + steps { + sh 'echo Print Maven Version' + sh 'mvn -version ' + } } - stages { - stage('Echo Version') { - steps { - // Get some code from a GitHub repository - sh 'echo Print Maven Version' - sh "mvn -version " - } - } - stage('Build') { - steps { - // Get some code from a GitHub repository (not needed if the file is part of repo ) - // git branch: 'main', changelog: false, credentialsId: 'forgejo-https', poll: false, url: 'https://forgejo.tben.online/sandbox/jenkins-hello-world.git' - // Run Maven package - sh "mvn clean package -DskipTests=true" - } - } - stage('Unit Test') { - steps { - script { - for (int i = 0 ; i < 60; i++) { - echo "${i + 1}" - sleep 1 - } - - sh "mvn test" - } - } - } + stage('Build') { + steps { + sh 'mvn clean package -DskipTests=true' + archiveArtifacts 'target/hello-demo-*.jar' + } } -} + + stage('Unit Test') { + steps { + script { + sh "mvn test" + } + + } + } + + } + tools { + maven 'M398' + } +} \ No newline at end of file