I've an Angular project on a Bitbucket repository. I created this pipeline that deploys the application on AWS S3 and invalidate the CloudFront distribution. Everything works fine. I would like to add the build number to the published version in order to know not just the version of the application but also the build that generated it.
image: cypress/browsers:node14.17.0-chrome88-ff89
options:
max-time: 120
pipelines:
branches:
master:
- step:
runs-on:
- 'self.hosted'
- 'linux'
size: 4x
caches:
- node
script:
- npm install
- npm install -g @angular/cli
- npm run build-stage --progress=false
artifacts:
- dist/**
- step:
runs-on:
- 'self.hosted'
- 'linux'
size: 4x
name: Deploy on AWS S3 and CloudFront invalidation
deployment: staging
script:
- pipe: atlassian/aws-s3-deploy:1.1.0
variables:
AWS_ACCESS_KEY_ID: $AWS_ACCESS_KEY_ID
AWS_SECRET_ACCESS_KEY: $AWS_SECRET_ACCESS_KEY
S3_BUCKET: 'xxxxxxx/dist'
LOCAL_PATH: 'dist'
DELETE_FLAG: 'true'
DEBUG: 'true'
- pipe: atlassian/aws-cloudfront-invalidate:0.6.0
variables:
AWS_ACCESS_KEY_ID: $AWS_ACCESS_KEY_ID
AWS_SECRET_ACCESS_KEY: $AWS_SECRET_ACCESS_KEY
DISTRIBUTION_ID: "xxxxxxx"
PATHS: "/*"
definitions:
caches:
npm: $HOME/.npm
cypress: $HOME/.cache/Cypress
and this is the initial part of my package.json:
{
"name": "myApp",
"version": "22.01.36"
}
I'd like the final version shown to the user is 22.01.36bxx (where xx is the Bitbucket build number). I think I just need a replacement in the package.json file. Do you have some suggestion to accomplish the "mission"?