diff --git a/script/generate_build_info.sh b/script/generate_build_info.sh new file mode 100644 index 00000000..013d8196 --- /dev/null +++ b/script/generate_build_info.sh @@ -0,0 +1,110 @@ +#!/bin/bash +# +# script/generate_build_info: Generates buildinfo.html and buildinfo.json and +# places them in a publically accessable static asset +# folder + +source "$(dirname "${0}")"/../script/include/global_header.inc.sh + +# Config +APP_NAME="ATST" +BUILD_URL="https://travis-ci.org/$TRAVIS_REPO_SLUG/builds/$TRAVIS_BUILD_ID" +STATIC_DIR="./static" + +echo "### Generate Build Info ###" + +echo "Gathering info from git..." +COMMIT_AUTHOR=$(git log -1 --pretty=%aN) +COMMIT_AUTHOR_EMAIL=$(git log -1 --pretty=%aE) +# Escape all double quotes in commit message and switch newlines for \n +# (for JSON compatability) +COMMIT_MESSAGE_JSON=$(git log -1 --pretty=format:%B | sed -e 's#\([^\\]\)"#\1\\"#g' | awk 1 ORS='\\n') +# Escape all < and > characters in commit message, insert pivotal story links, +# and trade newlines for
tags +COMMIT_MESSAGE_HTML=$(git log -1 --pretty=format:%B | sed -e 's#>#>#g' | sed -e 's#<#<#g' | awk 1 ORS='
') + +# Assemble https based git repo url +GIT_REPO=$(git config --get remote.origin.url | cut -d ':' -f 2) +GIT_URL="https://github.com/${GIT_REPO}" +# Drop the trailing .git for generating github links +GITHUB_BASE_URL="${GIT_URL%.git}" + +APP_CONTAINER_CREATE_DATE=$(date '+%Y-%m-%d') +APP_CONTAINER_CREATE_TIME=$(date '+%H:%M:%S') + +echo "Generating public/buildinfo.json ..." +cat > ${STATIC_DIR}/buildinfo.json < ${STATIC_DIR}/buildinfo.html < + + ${APP_NAME} build ${BUILD_NUMBER} info + + + + + + + + + + + + + + + + + + + + + + + + + + + +
BuildInfo
App Package Creation Time:${APP_CONTAINER_CREATE_DATE} ${APP_CONTAINER_CREATE_TIME}
Build Number:${BUILD_NUMBER}
Commit SHA:${TRAVIS_COMMIT}
Commit Author:${COMMIT_AUTHOR} <${COMMIT_AUTHOR_EMAIL}>
Commit Message:${COMMIT_MESSAGE_HTML}
+ + +ENDHTML