maven picking up environment variable set by jenkins

I am using the following maven pom.xml snippet to read a property called BUILD_NUMBER from a file jenkins/


Jenkins also has an environment variable called $BUILD_NUMBER. I have child pom.xmls which try and use the $BUILD_NUMBER, and it keeps picking up the Jenkins environment variable value for $BUILD_NUMBER instead of the one from jenkins/ I am just wondering if maven puts values it reads from files into the environment? If so, it looks as though Jenkins is over writing this value…

  • How can I get all build numbers of particular job in jenkins using groovy script?
  • How to configure Jenkins StarTeam plugin?
  • How to set up TestNG+Jenkins
  • How to pass output from an upstream project to downstream projects in Jenkins
  • Run docker after building own image
  • getting gradle to execute JUnit Test (Android app, Android Studio)
  • Jenkins access private BitBucket repo over SSH
  • Using Jenkins Version Environment Variable in the MSBuild step
  • Only run unit tests which's respective source code has changed?
  • Jenkins with pylint gives build failure
  • Rest API for disconnect/reconnect slave from Jenkins
  • Legacy code started this job. No cause information is available
  • 2 Solutions collect form web for “maven picking up environment variable set by jenkins”

    What makes you think ${project.parent.basedir} evaluates to anything useful?

    I’d say your <file> points to a non-existing file, so the properties-maven-plugin does not read any properties, so BUILD_NUMBER is not defined as a property, and ${BUILD_NUMBER} falls back to ${env.BUILD_NUMBER}, which is your Jenkins environment variable.

    I changed the BUILD_NUMBER variable to a different name so that it didn’t clash with the Jenkins $BUILD_NUMBER environment variable. That seems to have fixed the problem. Thanks for the help – set me on the right track.

    Git Baby is a git and github fan, let's start git clone.