From e572b0705f1b8931d2d9b9e6b5808980d7e45d77 Mon Sep 17 00:00:00 2001 From: Navin Soni Date: Sat, 26 Feb 2022 00:49:06 +0000 Subject: [PATCH] change: update code to get commit_id in codepipeline --- tests/scripts/run-notebook-test.sh | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/tests/scripts/run-notebook-test.sh b/tests/scripts/run-notebook-test.sh index b8a6e9bbf4..49fcebdaa2 100755 --- a/tests/scripts/run-notebook-test.sh +++ b/tests/scripts/run-notebook-test.sh @@ -81,8 +81,15 @@ echo "$LIFECYCLE_CONFIG_CONTENT" set -euo pipefail +# git doesn't work in codepipeline, use CODEBUILD_RESOLVED_SOURCE_VERSION to get commit id +codebuild_initiator="${CODEBUILD_INITIATOR:-0}" +if [ "${codebuild_initiator:0:12}" == "codepipeline" ]; then + COMMIT_ID="${CODEBUILD_RESOLVED_SOURCE_VERSION}" +else + COMMIT_ID=$(git rev-parse --short HEAD) +fi + ACCOUNT_ID=$(aws sts get-caller-identity --query Account --output text) -COMMIT_ID=$(git rev-parse --short HEAD) LIFECYCLE_CONFIG_NAME="install-python-sdk-$COMMIT_ID" python setup.py sdist