Issue
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.
And the error:
Thank you very much.
Solution
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"
}
Answered By - Moro
Answer Checked By - Senaida (JavaFixing Volunteer)