Skip to content

Commit 9ed6773

Browse files
committed
Fix up environment variables in codebuild codecov cmake build
Correctly set the environment variables VCS_COMMIT_ID and VCS_PULL_REQUEST which are used by the codecov bash script to commit coverage data to codecov and associate it with the correct commit/PR.
1 parent 3cdee52 commit 9ed6773

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

Diff for: buildspec-linux-cmake-gcc-cov.yml

+4-1
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,10 @@ phases:
2323
post_build:
2424
commands:
2525
- lcov --capture --directory build --output-file lcov.info
26-
- VCS_PULL_REQUEST=$(echo $CODEBUILD_SOURCE_VERSION | sed 's/pr\///g')
26+
# If $CODEBUILD_SOURCE_VERSION starts with 'pr/', filter out pr number, if not, return empty
27+
- VCS_PULL_REQUEST=$(echo $CODEBUILD_SOURCE_VERSION | sed '/^pr\//!d;s/^pr\///')
28+
# If $CODEBUILD_SOURCE_VERSION is commit id, set $VCS_COMMIT_ID
29+
- VCS_COMMIT_ID=$(echo $CODEBUILD_SOURCE_VERSION | sed -r '/^[a-z0-9]{40}$/!d')
2730
- COV_SCRIPT=/root/.cache/codecov.sh
2831
- if [ ! -f "$COV_SCRIPT" ]; then curl -s https://codecov.io/bash > "$COV_SCRIPT"; fi
2932
- bash "$COV_SCRIPT" -t "$CODECOV_TOKEN" || true

0 commit comments

Comments
 (0)