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

Support for overriding value of BUILDS_ALL_TIME (etc.) by environment-variables

    Details

    • Similar Issues:

      Description

      Status Quo:

      Currently, the values for ${BUILDS_ALL_TIME}, ${BUILDS_TODAY}, ${BUILDS_THIS_MONTH} and ${BUILDS_THIS_YEAR} will only increase by 1 for each new (successful) build. The only exception to this is explicitly overriding the next value by hand.

      Problem:

      For automated builds this is not practicable, because it requires way too much manual interaction / modification.

      Sometimes it would be beneficial if another (upstream) build-job could provide a new number for one of these values or if it could be calculated outside of Jenkins and injected into the build-process.

      Feature-Request:

      A useful extension to the versionnumber plugin which solves this short-coming would be to extend the usage of the form-fields in the job-configuration (, which currently are only used to override - by hand - the next value with a number):

      Instead of just taking a number which overrides the value for the next build, it should be possible to provide an environment-variable in this field. This environment-variable should then be checked during the next build and its value used as the corresponding number.
      However, if during the next build that environment-variable is not set or its value is not convertible into an integer, the standard behavior should kick in as if the field would have been left blank. (This means, the corresponding value of the previous build should be taken and increased by 1, and that value should be used instead.)

      Solution:

      I already have implemented this extension and will provide a pull-request.
      I hope others will find this extension useful so that it gets integrated.

        Attachments

          Activity

          Hide
          bahadir Deniz Bahadir added a comment - - edited

          I provided my changes in this pull-request 6.

          However, as I am unsure how this issue-tracking system is supposed to work and why I am able to make myself an issue-assignee, I do not think it would be correct if I change the progress-marker to "resolved" as long as no maintainer has accepted and merged the pull-request.
          Please feel free to give me instructions how to proceed from here.
          Thanks.

          Show
          bahadir Deniz Bahadir added a comment - - edited I provided my changes in this pull-request 6 . However, as I am unsure how this issue-tracking system is supposed to work and why I am able to make myself an issue-assignee, I do not think it would be correct if I change the progress-marker to "resolved" as long as no maintainer has accepted and merged the pull-request. Please feel free to give me instructions how to proceed from here. Thanks.
          Hide
          bahadir Deniz Bahadir added a comment -

          Because I realized that my former pull-request does not allow upgrading the plugin smoothly without manual interaction, I changed the code a little bit and provided another pull-request.

          This pull-request 7 allows to upgrade the plugin smoothly.

          Show
          bahadir Deniz Bahadir added a comment - Because I realized that my former pull-request does not allow upgrading the plugin smoothly without manual interaction, I changed the code a little bit and provided another pull-request. This pull-request 7 allows to upgrade the plugin smoothly.
          Hide
          scm_issue_link SCM/JIRA link daemon added a comment -

          Code changed in jenkins
          User: Deniz Bahadir
          Path:
          src/main/java/org/jvnet/hudson/tools/versionnumber/VersionNumberBuilder.java
          src/main/webapp/help-overrideNumbers.html
          src/test/java/org/jvnet/hudson/tools/versionnumber/VersionNumberBuilderTest.java
          http://jenkins-ci.org/commit/versionnumber-plugin/5a669b533deb9bfbed6d4cd1e7345e3111a70d0a
          Log:
          [FIXED JENKINS-29134]

          Added support for automatically overriding the values of "BUILDS_TODAY",
          "BUILDS_THIS_MONTH", "BUILDS_THIS_YEAR" and "BUILDS_ALL_TIME" with
          values taken from environment-variables.

          Instead of just providing a simple number in the form-fields of the
          job's plugin-configuration which overrides the value for the next build,
          one can now provide an environment-variable whose value will be
          extracted and used instead during the next builds.
          If it is not set or its value is not convertible to a positive integer,
          the value of the previous build will be taken instead and increased by
          one.

          Signed-off-by: Deniz Bahadir <dbahadir@benocs.com>

          Show
          scm_issue_link SCM/JIRA link daemon added a comment - Code changed in jenkins User: Deniz Bahadir Path: src/main/java/org/jvnet/hudson/tools/versionnumber/VersionNumberBuilder.java src/main/webapp/help-overrideNumbers.html src/test/java/org/jvnet/hudson/tools/versionnumber/VersionNumberBuilderTest.java http://jenkins-ci.org/commit/versionnumber-plugin/5a669b533deb9bfbed6d4cd1e7345e3111a70d0a Log: [FIXED JENKINS-29134] Added support for automatically overriding the values of "BUILDS_TODAY", "BUILDS_THIS_MONTH", "BUILDS_THIS_YEAR" and "BUILDS_ALL_TIME" with values taken from environment-variables. Instead of just providing a simple number in the form-fields of the job's plugin-configuration which overrides the value for the next build, one can now provide an environment-variable whose value will be extracted and used instead during the next builds. If it is not set or its value is not convertible to a positive integer, the value of the previous build will be taken instead and increased by one. Signed-off-by: Deniz Bahadir <dbahadir@benocs.com>
          Hide
          scm_issue_link SCM/JIRA link daemon added a comment -

          Code changed in jenkins
          User: Deniz Bahadir
          Path:
          src/main/java/org/jvnet/hudson/tools/versionnumber/VersionNumberBuilder.java
          http://jenkins-ci.org/commit/versionnumber-plugin/25537f0cfc97bbd0702e6b4a27e8306a0cafbac3
          Log:
          [FIXED JENKINS-29134] cont.

          • Added null-check for user-input.
          • Trimming user-input.

          Signed-off-by: Deniz Bahadir <dbahadir@benocs.com>

          Show
          scm_issue_link SCM/JIRA link daemon added a comment - Code changed in jenkins User: Deniz Bahadir Path: src/main/java/org/jvnet/hudson/tools/versionnumber/VersionNumberBuilder.java http://jenkins-ci.org/commit/versionnumber-plugin/25537f0cfc97bbd0702e6b4a27e8306a0cafbac3 Log: [FIXED JENKINS-29134] cont. Added null-check for user-input. Trimming user-input. Signed-off-by: Deniz Bahadir <dbahadir@benocs.com>
          Hide
          scm_issue_link SCM/JIRA link daemon added a comment -

          Code changed in jenkins
          User: Deniz Bahadir
          Path:
          src/main/java/org/jvnet/hudson/tools/versionnumber/VersionNumberBuilder.java
          http://jenkins-ci.org/commit/versionnumber-plugin/9c1a033923f6bc4b80a19cf682f03994f405695a
          Log:
          [FIXED JENKINS-29134] cont.

          • Renamed constant "envVarPattern" to "ENV_VAR_PATTERN".

          Signed-off-by: Deniz Bahadir <dbahadir@benocs.com>

          Show
          scm_issue_link SCM/JIRA link daemon added a comment - Code changed in jenkins User: Deniz Bahadir Path: src/main/java/org/jvnet/hudson/tools/versionnumber/VersionNumberBuilder.java http://jenkins-ci.org/commit/versionnumber-plugin/9c1a033923f6bc4b80a19cf682f03994f405695a Log: [FIXED JENKINS-29134] cont. Renamed constant "envVarPattern" to "ENV_VAR_PATTERN". Signed-off-by: Deniz Bahadir <dbahadir@benocs.com>
          Hide
          scm_issue_link SCM/JIRA link daemon added a comment -

          Code changed in jenkins
          User: Deniz Bahadir
          Path:
          src/main/java/org/jvnet/hudson/tools/versionnumber/VersionNumberBuilder.java
          src/main/webapp/help-overrideNumbers.html
          src/test/java/org/jvnet/hudson/tools/versionnumber/VersionNumberBuilderTest.java
          http://jenkins-ci.org/commit/versionnumber-plugin/b46718d598e0dbc3ec39cf81349bab8d012882ec
          Log:
          Merge pull request #7 from Bagira80/issue/JENKINS-29134

          [FIXED JENKINS-29134]

          Compare: https://github.com/jenkinsci/versionnumber-plugin/compare/786ffe3601c4...b46718d598e0

          Show
          scm_issue_link SCM/JIRA link daemon added a comment - Code changed in jenkins User: Deniz Bahadir Path: src/main/java/org/jvnet/hudson/tools/versionnumber/VersionNumberBuilder.java src/main/webapp/help-overrideNumbers.html src/test/java/org/jvnet/hudson/tools/versionnumber/VersionNumberBuilderTest.java http://jenkins-ci.org/commit/versionnumber-plugin/b46718d598e0dbc3ec39cf81349bab8d012882ec Log: Merge pull request #7 from Bagira80/issue/ JENKINS-29134 [FIXED JENKINS-29134] Compare: https://github.com/jenkinsci/versionnumber-plugin/compare/786ffe3601c4...b46718d598e0
          Hide
          bahadir Deniz Bahadir added a comment -

          The associated pull-request was merged and this feature will appear in the next version of the plugin.

          Show
          bahadir Deniz Bahadir added a comment - The associated pull-request was merged and this feature will appear in the next version of the plugin.

            People

            • Assignee:
              bahadir Deniz Bahadir
              Reporter:
              bahadir Deniz Bahadir
            • Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved: