Uploaded image for project: 'Jenkins'
  1. Jenkins
  2. JENKINS-26520

Environment Variables BUILD_ID and BUILD_NUMBER now return the same value

    XMLWordPrintable

Details

    • Bug
    • Status: Resolved (View Workflow)
    • Minor
    • Resolution: Won't Fix
    • core
    • None
    • Since version 1.597

    Description

      With this release jenkins changed the build identifier to the build number (instead of timestamp). Now the BUILD_NUMBER and BUILD_ID both return the build number and there is no way to get the timestamp from the environment variables.
      According to the documentation BUILD_ID should return the timestamp.

      BUILD_ID
      The current build id, such as "2005-08-22_23-59-59" (YYYY-MM-DD_hh-mm-ss)

      Possible fixes:

      • Change BUILD_ID to return the timestamp
      • Add Env-Var BUILD_TIMESTAMP or similar

      Attachments

        Issue Links

          Activity

            mre_mchp Michael Rentschler added a comment - - edited

            @Chris
            There is still a bug inside the ZenTimestamp Plugin. Once this is fixed, you do not have to check this option in every Jenkins job configuration.
            It should be enough to install the ZenTimestamp plugin. Then the BUILD_TIMESTAMP variable will be set to its default format.
            So far, until this issue inside the ZenTimestamp plugin was fixed, you have to set it in every job config (like you noticed).
            Or, as a simple workaround, set the ZenTimestamp format on the global Jenkins configuration page. That option should apply for all jobs then. (Jeff was faster here
            Once the plugin was fixed, even this check box is not necessary anymore. See the last comments on the reopened issue JENKINS-26626

            mre_mchp Michael Rentschler added a comment - - edited @Chris There is still a bug inside the ZenTimestamp Plugin. Once this is fixed, you do not have to check this option in every Jenkins job configuration. It should be enough to install the ZenTimestamp plugin. Then the BUILD_TIMESTAMP variable will be set to its default format. So far, until this issue inside the ZenTimestamp plugin was fixed, you have to set it in every job config (like you noticed). Or, as a simple workaround, set the ZenTimestamp format on the global Jenkins configuration page. That option should apply for all jobs then. (Jeff was faster here Once the plugin was fixed, even this check box is not necessary anymore. See the last comments on the reopened issue JENKINS-26626
            cojeff Jeff Foege added a comment -

            You can specify the format in the Manage Jenkins > Configure System > Global Properties then just pass the Build_Timestamp variable to your Build_ID variable you were using in your scripts. I was able to get this to work exactly without too much code changes. If some other project wants to use a different time stamp format then you will have that ability to change it at the project level.

            cojeff Jeff Foege added a comment - You can specify the format in the Manage Jenkins > Configure System > Global Properties then just pass the Build_Timestamp variable to your Build_ID variable you were using in your scripts. I was able to get this to work exactly without too much code changes. If some other project wants to use a different time stamp format then you will have that ability to change it at the project level.
            tobeychris Chris Tobey added a comment - - edited

            I tried a test with one of my jobs and the zen-timestamp plugin.

            I had the line "Changing BUILD_ID variable (job build time) with the date pattern yyyy-MM-dd_HH-mm-ss." in my log 10+ times.

            You also have to specify this option in EVERY individual build? How is this at all an acceptable replacement?

            Why can we not make BUILD_TIMESTAMP a Jenkins default variable?

            tobeychris Chris Tobey added a comment - - edited I tried a test with one of my jobs and the zen-timestamp plugin. I had the line "Changing BUILD_ID variable (job build time) with the date pattern yyyy-MM-dd_HH-mm-ss." in my log 10+ times. You also have to specify this option in EVERY individual build? How is this at all an acceptable replacement? Why can we not make BUILD_TIMESTAMP a Jenkins default variable?

            Thanks @michael and @Malcom,

            Yes, it works fine after specifying proper time pattern.

            It would be great help if author add litle description here in wiki ? as like other plugins.

            swapnilvkotwal Swapnil Kotwal added a comment - Thanks @michael and @Malcom, Yes, it works fine after specifying proper time pattern. It would be great help if author add litle description here in wiki ? as like other plugins.

            That's right. The actual behavior of the Zen-Timestamp plugin is to modify the environment variable only if "Change date pattern" was checked. With older Jenkins versions, the variable BUILD_ID was
            already set to the default format by the Jenkins core and was only modified by the plugin if this option was checked and a different format was selected. The new Zen plugin must be fixed to set the BUILD_TIMESTAMP variable in any case, even if there was no format defined inside the job or node configuration. I will file a ticket for this issue.

            mre_mchp Michael Rentschler added a comment - That's right. The actual behavior of the Zen-Timestamp plugin is to modify the environment variable only if "Change date pattern" was checked. With older Jenkins versions, the variable BUILD_ID was already set to the default format by the Jenkins core and was only modified by the plugin if this option was checked and a different format was selected. The new Zen plugin must be fixed to set the BUILD_TIMESTAMP variable in any case, even if there was no format defined inside the job or node configuration. I will file a ticket for this issue.

            People

              jglick Jesse Glick
              applican David Sommer
              Votes:
              20 Vote for this issue
              Watchers:
              33 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: