Skip to content

Commit

Permalink
.kokoro: publish test log to Build Cop Bot (#2775)
Browse files Browse the repository at this point in the history
  • Loading branch information
tbpg authored Feb 10, 2020
1 parent 272b61f commit 2b3daa3
Showing 1 changed file with 25 additions and 0 deletions.
25 changes: 25 additions & 0 deletions .kokoro/tests/run_tests.sh
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,31 @@ for file in **/requirements.txt; do
nox -s "$RUN_TESTS_SESSION"
EXIT=$?

# If this is a continuous build, send the test log to the Build Cop Bot.
# See https://github.com/googleapis/repo-automation-bots/tree/master/packages/buildcop.
if [[ $KOKORO_BUILD_ARTIFACTS_SUBDIR = *"continuous"* ]]; then
XML=$(base64 -w 0 sponge_log.xml)

# See https://github.com/apps/build-cop-bot/installations/5943459.
MESSAGE=$(cat <<EOF
{
"Name": "buildcop",
"Type" : "function",
"Location": "us-central1",
"installation": {"id": "5943459"},
"repo": "GoogleCloudPlatform/python-docs-samples",
"buildID": "$KOKORO_GIT_COMMIT",
"buildURL": "https://source.cloud.google.com/results/invocations/$KOKORO_BUILD_ID",
"xunitXML": "$XML"
}
EOF
)

# Use a service account with access to the repo-automation-bots project.
gcloud auth activate-service-account --key-file $GOOGLE_APPLICATION_CREDENTIALS
gcloud pubsub topics publish passthrough --project=repo-automation-bots --message="$MESSAGE"
fi

if [[ $EXIT -ne 0 ]]; then
RTN=1
echo -e "\n Testing failed: Nox returned a non-zero exit code. \n"
Expand Down

0 comments on commit 2b3daa3

Please sign in to comment.