Closed lovato closed 5 years ago
`image: atlassian/default-image:2
pipelines: branches: develop:
image: atlassian/pipelines-awscli
script:
- export BUILD_NUMBER=$(date +%Y%m%d%H%M%S)
- env
- mv ./src/assets/js/constants-dev.js ./src/assets/js/constants.js
- sed -i "s/DEPLOY_PATH/$BUILD_NUMBER/g" ./src/assets/js/constants.js
- rm ./src/assets/js/constants-local.js
- rm ./src/assets/js/constants-prod.js
- sed -i "s/constants-local/constants/g" ./src/index.html
- sed -i "s/assets/$BUILD_NUMBER\/assets/g" ./src/index.html
- mkdir ./src/$BUILD_NUMBER
- mv ./src/assets ./src/$BUILD_NUMBER/
- aws s3 sync --delete ./src s3://yyy
- aws cloudfront create-invalidation --distribution-id yyy --paths "/index.html"
master:
image: atlassian/pipelines-awscli
script:
- export BUILD_NUMBER=$(date +%Y%m%d%H%M%S)
- env
- mv src/assets/js/constants-prod.js src/assets/js/constants.js
- sed -i "s/DEPLOY_PATH/$BUILD_NUMBER/g" src/assets/js/constants.js
- rm src/assets/js/constants-local.js
- rm src/assets/js/constants-dev.js
- sed -i "s/\.development\.js/\.production\.min\.js/g" src/index.html
- sed -i "s/constants-local/constants/g" src/index.html
- sed -i "s/assets/$BUILD_NUMBER\/assets/g" src/index.html
- mkdir src/$BUILD_NUMBER
- mv src/assets src/$BUILD_NUMBER/
- aws s3 sync --delete ./src s3://xxx
- aws cloudfront create-invalidation --distribution-id xxx --paths "/index.html"
`
Just ran the command deploy.sh again ... it worked, even by issuing that very same error. The deploy actually happened. I have no idea why this error is being pushed to console.
I added a set -x
to my first command inside the step and was able to catch that the error was mine. Variables that do not exist locally are being sent empty to AWS commands.
If I run it interactively, it works.
My script called deploy.sh
bbrun $1 $2 $3 --pipeline branches:$BRANCH --env "AWS_SECRET_ACCESS_KEY=xxx, AWS_ACCESS_KEY_ID=yyy"
I made a script to basically copy everything to a /tmp area, and only them run bb in it. Else, it ends changing my project files, since I do npm install and I kind of change a few file contents depending on the deployment environment (dev / prod strings, stuff like that). But when running on Bitbucket, everything happens in a docker and gets disposed.
Anyway, the problem is that it fails directly. I also commented out my aws commands on yml file and it keeps saying "my aws command" is faulty. Interactively, it works like a charm.