• Icon: Bug Bug
    • Resolution: Unresolved
    • Icon: Major Major
    • maven-plugin
    • Jenkins 1.581
      Maven 3.0.5

      Hi,

      I'm currently facing an issue with the variable $POM_VERSION.
      I perform the following operations:

      1. Clean Workspace
      2. Checkout from Git (including the pom with Version 1.0.0)
      3. Execute Shell (or execute maven goal, both leads to the same result):
      mvn versions:set DnewVersion=${POM_VERSION}${BUILD_NUMBER};

      Now the POM-Version is set to e.g. 1.0.0-25.

      4. Publish 1.0.0-25 to Nexus

      So everything fine until now. I now Trigger the process the next time, but the variable $POM_VERSION still contains the value "1.0.0-25" from the last run, so the next artifact would be deployed as "1.0.0-25-26" and so on.

      I tried many things line unsetting the variables or copying them into other temp variables but I did not found a solution for this.

      Could you please check if POM_VERSION could be resetted at the beginning?

      Kind regards,

      Tobias

          [JENKINS-24869] POM_VERSION is not resetted

          tobias schaber created issue -

          Automatic assign.

          tobias schaber added a comment - Automatic assign.
          tobias schaber made changes -
          Labels New: maven

          Can reproduce.

          Kenneth Younger added a comment - Can reproduce.

          Neither the ws_cleanup nor git plugin wipeout workspace options alleviate the issue. Jenkins seems to have the pom cached somewhere.

          Niels Voorhoeve added a comment - Neither the ws_cleanup nor git plugin wipeout workspace options alleviate the issue. Jenkins seems to have the pom cached somewhere.
          Niels Voorhoeve made changes -
          Assignee New: Niels Voorhoeve [ niels ]
          Niels Voorhoeve made changes -
          Status Original: Open [ 1 ] New: In Progress [ 3 ]

          r04r r04r added a comment -

          This also affects me.

          r04r r04r added a comment - This also affects me.

          Patrick Ryan added a comment -

          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

          Patrick Ryan added a comment - 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

          Patrick Ryan added a comment - - edited

          To reproduce:
          restart jenkins
          pull from git (example: version=1.0.0-SNAPSHOT)
          echo ${POM_VERSION} (will probably be blank)
          invoke maven->validate
          echo ${POM_VERSION} (will be 1.0.0-SNAPSHOT)

          update version in repo and push (example: 1.0.1-SNAPSHOT)
          pull from git
          echo ${POM_VERSION} (will still be 1.0.0-SNAPSHOT, cached)
          invoke maven->validate
          echo ${POM_VERSION} (will still be 1.0.0-SNAPSHOT, not updated from maven invoke)

          My versions:
          Jenkins: 1.610
          Maven Integration Plugin: 2.10
          There is also -
          Maven Release Plug-in Plug-in: 0.14.0
          installed (i'm not using, but there are a lot of users on our jenkins, I hope this isn't interfering in anyway)

          Patrick Ryan added a comment - - edited To reproduce: restart jenkins pull from git (example: version=1.0.0-SNAPSHOT) echo ${POM_VERSION} (will probably be blank) invoke maven->validate echo ${POM_VERSION} (will be 1.0.0-SNAPSHOT) update version in repo and push (example: 1.0.1-SNAPSHOT) pull from git echo ${POM_VERSION} (will still be 1.0.0-SNAPSHOT, cached) invoke maven->validate echo ${POM_VERSION} (will still be 1.0.0-SNAPSHOT, not updated from maven invoke) My versions: Jenkins: 1.610 Maven Integration Plugin: 2.10 There is also - Maven Release Plug-in Plug-in: 0.14.0 installed (i'm not using, but there are a lot of users on our jenkins, I hope this isn't interfering in anyway)

            Unassigned Unassigned
            tobias_schaber tobias schaber
            Votes:
            28 Vote for this issue
            Watchers:
            31 Start watching this issue

              Created:
              Updated: