how to specify the pom.xml path in jenkins pipeline script

Multi tool use


how to specify the pom.xml path in jenkins pipeline script
my maven project looks like below
working dir
Jenkins error
this is how my script looks like
node {
stage ('Build') {
git url: 'https://github.com/rakshitha2/test_proj.git'
def mvnHome = tool 'M3'
bat "${mvnHome}binmvn -B install"
}
}
I have to go inside parent directory and execute maven command in Jenkins pipeline script.
I tried specifying POM path in MVN command its giving me an error saying "path is unexpected at this time". but the same is working in my local.
I'm new to Jenkins and groovy. kindly help me with this.
Hi, issue is not with the pom, I need to go inside parent directory where pom is located and execute the MVN command. but still I'm adding my error screen shot
– thakshira
Jun 15 '17 at 7:23
2 Answers
2
As it is basically a normal maven mechanism. So
sh 'mvn -f otherdirectory/pom.xml clean install'
pipeline {
agent any
tools {
maven 'mavenHome'
jdk 'JavaHome'
}
stages {
stage('Build') {
steps {
echo 'maven clean'
//ABC indicates the folder name where the pom.xml file resides
bat ' mvn -f ABC/pom.xml clean install'
}
post {
success {
echo 'Now Archiving'
}
}
}
}
}
By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.
add you pom.xml to question and the log of the error so people can understand the issue
– user7294900
Jun 15 '17 at 7:21