I'm running into a strange issue.
I have a multi-module maven project and in the pom parent I have a property called <build.number>
whose default value is latest
, then, in a submodule I'm using this property to be part of a docker image tag. Tagging the docker image works fine. Then I use the same property in an other submodule to replace one field in a deployment.yaml
file.
So in one module I tag the image an in the other I am pointing to that tagged image.
When I package the pom parent like this:
mvn clean package -Dbuild.number=1
it works fine. The last part of the image tag is -1
and the deployment file is replaced correctly.
What is the issue?
The issue arises when I package the project with Jenkins. I have a multibranch jenkins pipeline. When executing the jenkins pipeline it runs a mvn command like this:
mvn clean package -Dbuild.numer=${BUILD_NUMER}
${BUILD_NUMER}
should come from Jenkins.
After the execution, the image is tagged correctly but the field in the deployment.yaml
file is replaced but the value is latest
, the default value.
This is causing trouble because in the deployment file I must reference the right image. Having this reference pointing to latest
it is pointing to a wrong image.
Taking a look at the console logs I can see that the replacement process is being doing fine. One difference I noticed is in the maven.build.properties
file which is inside the submodule having the issue. I think this file was created at packaging the submodule. When I package the project locally the property build.number
in this file is the one I passed in the command line but when I package it with jenkins, the value in this file is latest
.
I don't know if it is an issue about Jenkins, multibranch pipeline, the way we are archiving the files, the location the file is archived or about maven.
NOTE: I had this project working fine before, using a non multibranch pipeline. After a server migration we started to use multibranch pipeline and we did not realize that it was failing until now.