0

We have a project called update-catalog. Inside that project we have two modules, one for the frontend application and the other for the java backend, which is also called update-catalog. There on the backend module we have our pom and maven wrapper. However, we are facing issues to find the wrapper and mvnw command is not found when attempting to run the tests from the Jenkins pipeline. There we do the checkout from git and probably need to change the directory to go inside the java app, but we're struggling to figure out the syntax on how to do this. Would appreciate some help here, please.

PS: Perhaps something like this but not too sure.

stage('Tests') {  
   steps {  
     dir('tests/path') {  
       sh './mvnw -f update-catalog surefire-report:report'  } 
     }
}

Here it's a picture of our project tree and Jenkins file.

enter image description here

And the error:

enter image description here

Thank you very much.

Francislainy Campos
  • 3,462
  • 4
  • 33
  • 81

1 Answers1

1

dir('') tells Jenkins where to execute the commands. From the picture I see your wrapper is inside the update-catalog. You seem to be on the right track, try this:

 dir('update-catalog') {  
   sh "./mvnw surefire-report:report"
 }
Francislainy Campos
  • 3,462
  • 4
  • 33
  • 81
Moro
  • 781
  • 4
  • 14
  • Thanks for your answer. I've tried it now but got the same error I'm afraid. – Francislainy Campos Apr 27 '22 at 14:22
  • The path in the screenshot is "apps/update-catalog/SonarQube/update-catalog/update-catalog/" you can try 'dir' into it. I would also check the workspace if you don't delete or debug the script by adding a simple sh "ls -al" before the ./mvnw line – Moro Apr 27 '22 at 14:29
  • apps/update-catalog/SonarQube is the path inside the jenkins job and the last /update-catalog/update-catalog inside the repo. – Francislainy Campos Apr 27 '22 at 14:40
  • This worked now, however. ```steps { dir('update-catalog') { sh "./mvnw surefire-report:report" } }``` – Francislainy Campos Apr 27 '22 at 14:40
  • I've updated and accepted your answer as that's what lead me to fix the issue. Thanks very much for your help here. – Francislainy Campos Apr 27 '22 at 14:42