Home > Net >  Spring Boot Microservices - Jenkinsfile "The goal you specified requires a project to execute b
Spring Boot Microservices - Jenkinsfile "The goal you specified requires a project to execute b

Time:01-31

I have a problem about running Jenkinsfile in Jenkins for my Spring Boot Microservices example.

I run Jenkins on Docker.

After implementing a required settings for Jenkins and creating Jenkinsfile in my Spring Boot Microservices example, I run the pipeline in Jenkins but I got an error.

Image

Here is the error message shown below.

  mvn clean install -D skipTests
[INFO] Scanning for projects...
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time:  0.053 s
[INFO] Finished at: 2023-01-29T01:07:58Z
[INFO] ------------------------------------------------------------------------
[ERROR] The goal you specified requires a project to execute but there is no POM in this directory (/var/jenkins_home/workspace/Spring Boot Microservices Pipeline). Please verify you invoked Maven from the correct directory. -> [Help 1]
[ERROR] 
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR] 
[ERROR] For more information about the errors and possible solutions, please read the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/MissingProjectException

How can I fix the issue?

Here is my repo : Link

Here is git backend system : Link

CodePudding user response:

In your repo (https://github.com/Rapter1990/springbootmicroservicedailybuffer) you have several pom.xml, but they are in subfolders, so you should enter them before running maven.

dir("apigateway") {
  sh "mvn clean install -DskipTests"
}
dir("auth-service") {
  sh "mvn clean install -DskipTests"
}
...

I also guess you could delete the "git" line in your Jenkinsfile, as Jenkins is already downloading the project to run it (you have your jenkinsfile and your source code in the same git repo)

CodePudding user response:

Here is the answer shown below.

pipeline {
    agent any
    tools {
        maven "Maven 3.6.3"
    }
    stages {
        stage("build project") {
            steps {
                // git 'https://github.com/Rapter1990/springbootmicroservicedailybuffer'
                echo "Java VERSION"
                sh 'java --version'
                echo "Maven VERSION"
                sh 'mvn --version'
                echo 'building project...'

                dir("service-registry") {
                  sh "mvn clean install"
                }

                dir("configserver") {
                  sh "mvn clean install"
                }

                dir("apigateway") {
                  sh "mvn clean install -DskipTests"
                }

                dir("auth-service") {
                  sh "mvn clean install -DskipTests"
                }

                dir("productservice") {
                  sh "mvn clean install -DskipTests"
                }

                dir("orderservice") {
                  sh "mvn clean install -DskipTests"
                }

                dir("paymentservice") {
                  sh "mvn clean install -DskipTests"
                }
            }
        }
    }
}
  • Related