Search code examples
jenkins-pipelinejenkins-email-ext

How to get maven version in Jenkins email notification when using emailext


How to get maven version in Jenkins email notification using emailext. I need to print the maven version, project is using, in the email notification. Please suggest.


Solution

  • Added below code to my groovy email template. It worked, fetched the maven version from the project pom in the email.

    <%  def variable = new XmlSlurper().parse(new File("/var/jenkins_home/jobs/projectName/pom.xml"))
           def param = new hudson.model.StringParameterValue("MAVEN_VERSION", variable.prerequisites.maven.toString())
           def version = param.getValue() %>
    <tr>
          <td>Maven:</td>
          <td>${version}</td>
        </tr>