Created
April 28, 2019 20:59
-
-
Save dylanvaughn/53638cab9dabb751c644b5055eebf057 to your computer and use it in GitHub Desktop.
better-codepipeline-metadata Bitbucket example
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
.installdeps: &installdeps | | |
apt-get update | |
apt-get -y install zip python-pip | |
pip install awscli | |
.exportvars: &exportvars | | |
export AWS_ACCESS_KEY_ID=$AWS_ACCESS_KEY_ID | |
export AWS_SECRET_ACCESS_KEY=$AWS_SECRET_ACCESS_KEY | |
.buildartifact: &buildartifact | | |
zip -q -r artifact.zip * | |
.generatesummary: &generatesummary | | |
# https://stackoverflow.com/questions/1441010/the-shortest-possible-output-from-git-log-containing-author-and-date#comment10995395_1441062 | |
SUMMARY=`git log -n 1 --pretty=format:"%h %ad%x09%an%x09%s" --date=short` | |
# replace newlines and tabs with a space | |
SUMMARY=${SUMMARY//$'\n'/ } | |
SUMMARY=${SUMMARY//$'\t'/ } | |
# escape double quotes | |
SUMMARY=${SUMMARY//$'"'/\\\"} | |
# limit length to 2010 | |
# documentation says 2048 for this field but in my testing it fails over 2010 | |
# https://docs.aws.amazon.com/codepipeline/latest/APIReference/API_ArtifactRevision.html | |
SUMMARY=`echo $SUMMARY | cut -c 1-2010` | |
export SUMMARY | |
.pushartifact: &pushartifact | | |
aws s3 cp artifact.zip s3://better-codepipeline-metadata/ --metadata "{\"codepipeline-artifact-revision-summary\":\"$SUMMARY\"}" | |
pipelines: | |
default: | |
- step: | |
script: | |
- *installdeps | |
- *exportvars | |
- *buildartifact | |
- *generatesummary | |
- *pushartifact |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment