Name: My Software
Version: 1.0.5
Release: 1
Summary: This is my software
Not sure if anyone has tried this before or if it is easy, but:
A spec file has two unique indicators for its version:
- Version (which specifies software version)
- Release (which specifies the package's number - if you build an RPM, it's broken, and build another one, you up the 'Release' number.
I'm wondering if anyone has tried, or knows how, I could use the Jenkins $BUILD_NUMBER variable to dynamically change the Release
number, thereby increasing the Release
number every time a new successful build completes...?
In my Jenkins setup, I've decided to bypass the build number with regards to the RPM version numbering completely. Instead, I use a home-made script that generates and keeps track of the various releases that are being generated.
In my spec file:
And in the Jenkins build script:
rpm-release-number.py
is a simple script that maintains a file-based database (in JSON format, for easy maintenance). It can handle being run at the same time, so no worries there, but it won't work if you have build slaves (as far as I can tell, I don't use them so can't test). You can find the source code and documentation here.The result is that I get the following package versioning scheme:
PS: Note that the Jenkins build script is just an example, the logic behind creating the rpmbuild directory structure and retrieving the .src.rpm and .spec file names is a bit more complicated.
I've been using the Jenkins build number as the 'release' and packaging via fpm.
Couple fpm with some globals provided by Jenkins
There's some nebulous variables in the example command below, but
$BUILD_NUMBER
is what I'm using for the release here (fpm calls it iteration instead).It's been a long time... and thankfully I have no rpm based systems so I can't test this.
You can pass parameters to
rpmbuild
on the commandlinerpmbuild --define="version = ${env.BUILD_NUMBER}
It would be helpful to post snippets of the spec and the script you're using to build the rpm. You don't want your build script editing the spec file, which I'm assuming it's pulling out down from some source control.