Provide a mechanism to obtain an ever increasing build number

Description

Currently when a project needs to generate unique names for artifacts, they have to use mechanisms like embedding the date and/or the git hash into the artifact name. For example, when a new build of the Ruby SDK is generated, the name of the RPM is like this:

rubygem-ovirt-engine-sdk4-4.2.0-1.alpha0.20170505gita6de891.el7.centos.ppc64le.rpm

That information is useful, and usually unique. But can be repeated if the same jobs is manually triggered the same day, as the date and the git hash will be the same.

In addition the date may be misleading, because a build performed later but using an old commit, will look newer than an older build that uses a newer commit.

A possible solution is to count the number of commits since certain well known commit. But this isn't reliable if the repository isn't completely cloned, for example if it is cloned with '--depth 1', as that well known commit may not be in the cloned repository. That cloning out of the control of the automation scripts.

So my suggestion/request is to add to the CI/CD environment a mechanism to provide that sequence to the jobs explicitly. I'd suggest to use the count of commits since the initial commit of the repository. The CI/CD environment performs the clone, so it can make sure it has all the relevant commits.

This information could be passed to the build-artifacts.sh script in an environment variable, or in the command line, or in a file in a known location.

With that each project could (optionally) modify its automation scripts to include that number. for example, in the Ruby SDK I'd like to generate RPMs like this:

rubygem-ovirt-engine-sdk4-4.2.0-1.alpha0.<that-number>.rpm

Activity

Show:

Barak Korren June 24, 2018 at 8:09 AM

Not going to add this - implementing this would require storing state in the CI system, and would be prone to failure if that state is corrupted or lost.

This would also make the build version not reproducible.

git describe provides a better mechanism to achieve what is needed in a stateless and reproducible manner.

Barak Korren May 12, 2017 at 12:10 PM

While this is something we can look into, I think in the short term just counting commits from last tag with something like 'git describe' should be enough. It is not likely that we'll switch to shallow cloning any time soon because we know that there are project that are using 'git describe'.

Won't Fix

Details

Assignee

Reporter

Components

Priority

Created May 12, 2017 at 11:46 AM
Updated September 2, 2018 at 3:50 PM
Resolved June 24, 2018 at 8:09 AM