I am using trying to deploy a Python Flask app to an Azure App Service using BitBucket Pipelines. I am also trying to included the latest commit Id when deploying. For this I am using Git Attributes.
In my base.html file, I have added "$Format:Version: %h$" to a span element. In my .gitattributes file, I have added "*.html text export-subst" as a entry (on its own line).
When I run `git archive` locally, it works as expected: "$Format:Version: %h$" is replaced with "Version: xxxxxxx". But when I use the same `git archive` command in my bitbucket-pipelines.yml, that format is not replaced at all. What Am I doing wrong?
bitbucket-pipelines.yml
image: atlassian/default-image:3
pipelines:
branches:
dev:
- step:
name: "Build"
script:
- git archive --format zip -v --worktree-attributes -o ./app-$BITBUCKET_BUILD_NUMBER.zip HEAD
artifacts:
- app-*.zip
- step:
name: 'Deployment to Dev'
deployment: test
script:
- pipe: atlassian/azure-web-apps-deploy:1.0.1
variables:
AZURE_APP_ID: $AZURE_APP_ID
AZURE_PASSWORD: $AZURE_PASSWORD
AZURE_TENANT_ID: $AZURE_TENANT_ID
AZURE_RESOURCE_GROUP: $AZURE_RESOURCE_GROUP
AZURE_APP_NAME: 'AppServiceName'
ZIP_FILE: 'app-$BITBUCKET_BUILD_NUMBER.zip'
I tried another solution creating a shell script (`build.sh`) and using `sed` to replace the `$Format:Version: %h$` string. That does not work either.
The sed commands I used:
sed -i "s/\$Format:Version: %h\\$/Version\: ${BITBUCKET_COMMIT: -7}/g" $(grep --include \*.html -l -r . -e '\$Format:Version: %h\$')