0
votes

I am trying to build a Java application with maven 3.6.1 via Azure Pipelines.

How can I reference predefined variables that are exposed by the pipeline in my build > finalName in my POM file?

https://docs.microsoft.com/en-us/azure/devops/pipelines/build/variables?view=azure-devops&tabs=yaml

I am trying something like this but it is not resolving:

<build>
    <finalName>${project.artifactId}-${project.version}-${env.Build.BuildNumber}</finalName>

For my pipeline, I am using ubuntu-latest image when doing the build.

1

1 Answers

0
votes

Solved it by adding a BUILD_NUMBER variable to azure-pipelines.yml:

variables:
  MAVEN_CACHE_FOLDER: $(Pipeline.Workspace)/.m2/repository
  MAVEN_OPTS: '-Dmaven.repo.local=$(MAVEN_CACHE_FOLDER)'
  BUILD_NUMBER: $(Build.BuildNumber)

Then I was able to reference the build number:

<build>
    <finalName>${project.artifactId}-${project.version}-${env.BUILD_NUMBER}</finalName>