From 36b4d3c27d45088f34577ef6e71d0d0f1770132e Mon Sep 17 00:00:00 2001 From: Devon Mackay Date: Tue, 18 Sep 2018 14:09:37 -0400 Subject: [PATCH 01/10] Add build info script --- script/generate_build_info.sh | 110 ++++++++++++++++++++++++++++++++++ 1 file changed, 110 insertions(+) create mode 100644 script/generate_build_info.sh 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 From f84b6511c1c2507c30ff0c2049a1c398636b5b88 Mon Sep 17 00:00:00 2001 From: Devon Mackay Date: Wed, 19 Sep 2018 11:50:13 -0400 Subject: [PATCH 02/10] Update build info for CircleCI --- script/generate_build_info.sh | 39 +++++++++++++++++++++-------------- 1 file changed, 24 insertions(+), 15 deletions(-) diff --git a/script/generate_build_info.sh b/script/generate_build_info.sh index 013d8196..70aba7cb 100644 --- a/script/generate_build_info.sh +++ b/script/generate_build_info.sh @@ -4,11 +4,12 @@ # places them in a publically accessable static asset # folder -source "$(dirname "${0}")"/../script/include/global_header.inc.sh +#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" +CIRCLECI_WORKFLOW_BASEURL="https://circleci.com/workflow-run" +CIRCLECI_WORKFLOW_URL="${CIRCLECI_WORKFLOW_BASEURL}/${CIRCLE_WORKFLOW_ID}" STATIC_DIR="./static" echo "### Generate Build Info ###" @@ -16,11 +17,11 @@ echo "### Generate Build Info ###" echo "Gathering info from git..." COMMIT_AUTHOR=$(git log -1 --pretty=%aN) COMMIT_AUTHOR_EMAIL=$(git log -1 --pretty=%aE) +GIT_SHA=$(git rev-parse HEAD) # 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 +# Escape all < and > characters in commit message 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 @@ -28,6 +29,7 @@ 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}" +GITHUB_COMMIT_URL="${GITHUB_BASE_URL}/commit/${GIT_SHA}" APP_CONTAINER_CREATE_DATE=$(date '+%Y-%m-%d') APP_CONTAINER_CREATE_TIME=$(date '+%H:%M:%S') @@ -36,19 +38,22 @@ echo "Generating public/buildinfo.json ..." cat > ${STATIC_DIR}/buildinfo.json < ${STATIC_DIR}/buildinfo.html < - ${APP_NAME} build ${BUILD_NUMBER} info + ${APP_NAME} build ${CIRCLE_BUILD_NUM} info