Reputation: 125
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://learn.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.
Upvotes: 0
Views: 3490
Reputation: 125
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>
Upvotes: 3