Forums

Articles
Create
cancel
Showing results for 
Search instead for 
Did you mean: 

Auto create Bamboo build plans?

Marc
I'm New Here
I'm New Here
Those new to the Atlassian Community have posted less than three times. Give them a warm welcome!
October 29, 2018

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

2 answers

1 vote
Graham Gatus
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
November 1, 2018

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:

  • If you plan store the current version number in a file in your repo, when you increment it you will need to write and commit it back, so that the next pipeline than executes gets the next available version number. Theres several methods you can use to commit back to your repo from pipelines (and we're working on a feature at the moment to make this much easier) - see discussion at https://bitbucket.org/site/master/issues/13213/push-back-to-remote-from-pipelines for some information on how to configure pipelines to allow committing back.
  • If you don't want to trigger another pipeline directly after committing, the commit should have "[skip ci]" in the commit message (see 'Can I commit without triggering the pipeline" at https://confluence.atlassian.com/bitbucket/bitbucket-pipelines-faq-827104769.html.

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.

Graham Gatus
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
November 1, 2018

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}
0 votes
Marc
I'm New Here
I'm New Here
Those new to the Atlassian Community have posted less than three times. Give them a warm welcome!
October 30, 2018

Anyone please? I would appreciate some assistance.

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events