I noticed the POM variables are cached. After running Maven a couple of times I started using pre build scripts to do things with POM_GROUPID and others. After I updated some plugins and rebooted Jenkins, all the POM variables were gone. They don't return until you run some Maven target. (This is not very clear from the docs that make it should like the variables are always available.)
Once I figured this out, I started running the "validate" goal first thing, which gives me all the variables right away, including POM_VERSION. However, if you update the version before committing, POM_VERSION doesn't reflect the new version. Validate shows the real version but my echo shows the old:
[INFO] ------------------------------------------------------------------------
[INFO] Building Pipeline Test 1.0.5-SNAPSHOT
[INFO] ------------------------------------------------------------------------
[INFO]
[INFO] --- maven-enforcer-plugin:1.3.1:enforce (enforce-requirements) @ pipeline_test ---
[INFO]
[INFO] --- maven-enforcer-plugin:1.3.1:enforce (enforce-no-snapshots) @ pipeline_test ---
[INFO] Skipping Rule Enforcement.
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 0.749 s
[INFO] Finished at: 2015-08-20T08:35:27-07:00
[INFO] Final Memory: 8M/452M
[INFO] ------------------------------------------------------------------------
[workspace] $ /bin/sh -xe /tmp/hudson247321079861255193.sh
+ echo 'VERSION: 1.0.4.45'
VERSION: 1.0.4.45
Later in my build, I run versions:set and install and deploy and it seems like one of those will update the cache so the next run will get the version from the last run. I'm always one run behind. I am trying to set the version number myself for continuous delivery but cannot rely on POM_VERSION.
To get the version, I have been doing this (which is wasteful and ugly):
`mvn org.apache.maven.plugins:maven-help-plugin:2.1.1:evaluate -Dexpression=project.version | grep -v "\[" |grep "\-SNAPSHOT"`
Please update these variables whenever maven is invoked, never cache.
Bonus: Make the variables available immediately, without needing to run maven first.
Thanks
I noticed the POM variables are cached. After running Maven a couple of times I started using pre build scripts to do things with POM_GROUPID and others. After I updated some plugins and rebooted Jenkins, all the POM variables were gone. They don't return until you run some Maven target. (This is not very clear from the docs that make it should like the variables are always available.)
Once I figured this out, I started running the "validate" goal first thing, which gives me all the variables right away, including POM_VERSION. However, if you update the version before committing, POM_VERSION doesn't reflect the new version. Validate shows the real version but my echo shows the old:
[INFO] ------------------------------------------------------------------------ [INFO] Building Pipeline Test 1.0.5-SNAPSHOT [INFO] ------------------------------------------------------------------------ [INFO] [INFO] --- maven-enforcer-plugin:1.3.1:enforce (enforce-requirements) @ pipeline_test --- [INFO] [INFO] --- maven-enforcer-plugin:1.3.1:enforce (enforce-no-snapshots) @ pipeline_test --- [INFO] Skipping Rule Enforcement. [INFO] ------------------------------------------------------------------------ [INFO] BUILD SUCCESS [INFO] ------------------------------------------------------------------------ [INFO] Total time: 0.749 s [INFO] Finished at: 2015-08-20T08:35:27-07:00 [INFO] Final Memory: 8M/452M [INFO] ------------------------------------------------------------------------ [workspace] $ /bin/sh -xe /tmp/hudson247321079861255193.sh + echo 'VERSION: 1.0.4.45' VERSION: 1.0.4.45
Later in my build, I run versions:set and install and deploy and it seems like one of those will update the cache so the next run will get the version from the last run. I'm always one run behind. I am trying to set the version number myself for continuous delivery but cannot rely on POM_VERSION.
To get the version, I have been doing this (which is wasteful and ugly):
Please update these variables whenever maven is invoked, never cache.
Bonus: Make the variables available immediately, without needing to run maven first.
Thanks