Increasing Bitbucket Pipeline Number

I have netcoreapp1.0 , which I create using Bitbucket pipelines and pack using the dotnet pack , and click Octopus to deploy as MyAssembly.Api.1.0.0-beta - *. nupkg, where * number of the commit number / assembly (or any other stable incremented number).

Since commit identifiers in GIT are UUIDs, I tried the following commands (see below) to get a commit counter, but the total number of commits is very unreliable and does not work properly. Locally, I get that it works very well, and the number of transactions increases for each commit that I make for my local repo. Unfortunately, none of the commands works in the pipeline (works in the Docker container). For some reason, the number of fixations remains the same or even sometimes decreases.

I read somewhere that this is due to the “shallow / inexpressible” GIT repo blabla ... and that it can be resolved by logging in (before GIT) every time. I don’t want to do this if I can avoid it, and I find it kind of ironic that I will need to enter the GIT inside Bitbucket itself.

 git shortlog | grep -cE '^[ ]+\w+' git rev-list HEAD --count git rev-list --all --count git rev-list --no-merges --count HEAD git log --pretty=format:'' | wc -l git log master --pretty=oneline | wc -l 

Q: Is there any other way to increase the value and access it as a variable in the pipeline?

+5
source share
2 answers

As you already found out, this is not so simple or even intended to get an incremental number directly from the repository or git history.

Another way to read and set variables in Bitbucket streams is " Environement variables ".

What I would do to solve this problem is to set the environment variable with the desired initial value, and then increase the number in this environment variable directly in the script that runs in the Bitbucket pipeline.

+2
source

We can directly call $ BITBUCKET_BUILD_NUMBER to get the assembly number now, increasing the number of lines for each assembly in your repository, which is available as an environment variable.

https://bitbucket.org/site/master/issues/12838/build-number-that-increments-on-every

0
source

Source: https://habr.com/ru/post/1259411/


All Articles