1

I have a POM file that looks like this:

<?xml version="1.0" encoding="UTF-8"?>

<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
    <modelVersion>4.0.0</modelVersion>
    <groupId>com.capgemini.jira.plugin</groupId>
    <artifactId>security-service</artifactId>
    <version> ${POM_JIRAVERSION}-${BUILD_NUMBER}-SNAPSHOT</version>

I've got an HTML page where I want to display my POM version number, my version number is dynamic as you can see and changes with every build I make on Jenkins. How can retrieve the version from the Pom.xml and display it on my HTML ?

Jsef bch
  • 71
  • 1
  • 7
  • What is the question? – Cjmarkham Jan 23 '22 at 18:01
  • @Cmarkham Added it thanks – Jsef bch Jan 23 '22 at 18:03
  • 1
    You could access and pass it as an environment variable, read more here: https://stackoverflow.com/questions/57663555/how-to-access-environment-variables-from-the-front-end – gru Jan 23 '22 at 19:57
  • 1
    Keep in mind that you want to access the POM version (backend) in your HTML/JS (frontend). You need a solution that bridges this gap, e.g. with a build tool like webpack for injecting environment variables. – gru Jan 23 '22 at 20:00
  • 1
    Alternatively, you could implement a `GET` request in your Java backend, which returns the current version. You would query this method in your frontend JS then and display it. – gru Jan 23 '22 at 20:01

0 Answers0