Hello,
I'm trying to see if there is a way to auto increment build version number in my .NET assembly page from Bitbucket pipelines and it autoincrement by 1 each time the project/solution is build to Bitbucket. So the build number would be 1.3.1 and then 1.3.2 after the next On all pages of this website the build number is currently displayed as a label with the build number hard coded. I want to be able to auto increment this number thru Bitbucket but not sure how to do that? Does this make sense?
Thanks
Hi @Marc
Pipelines itself won't manage versioning (there is a $BITBUCKET_BUILD_NUMBER environment variable, but this probably wont fit into your versioning scheme) - you will need to use some tool to read the current version number from a file or external service, increment it by one, then write it back. Im not familiar with .NET, but for e.g with Java's maven build tool, it has plugins to manage versions, where the current version is stored in a file (in maven, the pom.xml file). I'd recommend following the semantic versioning scheme - https://semver.org/, and you should be able to find some .NET tools to help you to do this.
Theres 2 immediate issues here:
Doing a quick google search, I did find https://gitversion.readthedocs.io/en/latest/reference/intro-to-semver/ which can help manage versioning with a git project, and seems to be used in the .NET ecosystem. Skimming over the docs, it seems fairly feature packed. Someone else here with more .NET experience might be able to suggest better alternatives?
Another option - you could potentially store version numbers as git tags - each time you want to release a new version, fetch git tags that match a specific pattern (e.g 1.x.x), sort them, find the latest, and increment it by one. You can then git tag the next release, and push that tag back to your repository. This way, you avoid having to store any version numbers within your source files, but you will need to find (or write your own) tooling to support this scheme.
If you did want to use the bitbucket build number, you could do something like:
script:
- export VERSION=1.0.${BITBUCKET_BUILD_NUMBER}
# later, use ${VERSION} in scripts to update your pages
- update-html-page-version.sh ${VERSION}
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Anyone please? I would appreciate some assistance.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Online forums and learning are now in one easy-to-use experience.
By continuing, you accept the updated Community Terms of Use and acknowledge the Privacy Policy. Your public name, photo, and achievements may be publicly visible and available in search engines.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.