Skip to content

Commit

Permalink
add more trace
Browse files Browse the repository at this point in the history
  • Loading branch information
franklychilled committed Feb 26, 2024
1 parent c47825d commit 90b4ae1
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 11 deletions.
5 changes: 3 additions & 2 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,6 @@ services:
slack-notification:
image: ${BUILDKITE_PLUGIN_JUNIT_SLACK_NOTIFICATION_DOCKER_CACHE}node:21
environment:
SLACK_TOKEN: ${TOKEN_VALUE}
SLACK_CHANNEL: ${BUILDKITE_PLUGIN_JUNIT_SLACK_NOTIFICATION_SLACK_CHANNEL}
ARTIFACTS: ${BUILDKITE_PLUGIN_JUNIT_SLACK_NOTIFICATION_ARTIFACTS}
BUILDKITE_BRANCH: ${BUILDKITE_BRANCH}
BUILDKITE_BUILD_AUTHOR: ${BUILDKITE_BUILD_AUTHOR}
Expand All @@ -13,9 +11,12 @@ services:
BUILDKITE_COMMIT: ${BUILDKITE_COMMIT}
BUILDKITE_MESSAGE: ${BUILDKITE_MESSAGE}
BUILDKITE_PIPELINE_NAME: ${BUILDKITE_PIPELINE_NAME}
DEBUG: ${DEBUG}
EXTRA_SLACK_MESSAGE: ${EXTRA_SLACK_MESSAGE}
NPM_REGISTRY: ${NPM_REGISTRY}
NPM_TOKEN: ${NPM_TOKEN}
SLACK_CHANNEL: ${BUILDKITE_PLUGIN_JUNIT_SLACK_NOTIFICATION_SLACK_CHANNEL}
SLACK_TOKEN: ${TOKEN_VALUE}
TEST_SUITES_1_ARTIFACTS: ${BUILDKITE_PLUGIN_JUNIT_SLACK_NOTIFICATION_TEST_SUITES_1_ARTIFACTS}
TEST_SUITES_1_NAME: ${BUILDKITE_PLUGIN_JUNIT_SLACK_NOTIFICATION_TEST_SUITES_1_NAME}
TEST_SUITES_2_ARTIFACTS: ${BUILDKITE_PLUGIN_JUNIT_SLACK_NOTIFICATION_TEST_SUITES_2_ARTIFACTS}
Expand Down
6 changes: 6 additions & 0 deletions hooks/command
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,12 @@ EXTRA_SLACK_MESSAGE_ENV_NAME="$(plugin_read_config EXTRA_SLACK_MESSAGE_ENV_NAME
EXTRA_SLACK_MESSAGE=$(eval "echo \${$EXTRA_SLACK_MESSAGE_ENV_NAME:-}")
export EXTRA_SLACK_MESSAGE;

if [ -z "${EXTRA_SLACK_MESSAGE}" ]; then
echo "EXTRA_SLACK_MESSAGE is empty."
else
echo "EXTRA_SLACK_MESSAGE is: ${EXTRA_SLACK_MESSAGE}"
fi

PLUGIN_DIR="$(cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd)/.."

ARTIFACTS_DIR="$(pwd)/$(mktemp -d "junits-slack-notification-plugin-artifacts-tmp.XXXXXXXXXX")"
Expand Down
28 changes: 19 additions & 9 deletions src/runner.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,26 @@ import {sendResultToSlack} from "./slackNotification";
import {parseFiles} from "./xmlParser";
import {getStats} from "./testcaseStats";

function logEnvironmentVariableWhenDebugging() {
if (process.env.DEBUG === "true") {
// display all environment variables except tokens
Object.keys(process.env)
.filter(key => !key.includes("TOKEN"))
.forEach(key => {
console.log(`${key}: ${process.env[key]}`);
});
}
}

export const run = async (): Promise<void> => {
logEnvironmentVariableWhenDebugging();

if (!process.env.EXTRA_SLACK_MESSAGE) {
console.log("EXTRA_SLACK_MESSAGE is empty.");
} else {
console.log(`EXTRA_SLACK_MESSAGE is : ${process.env.EXTRA_SLACK_MESSAGE}`);
}

const commit: JunitResult = {
build_id: parseInt(process.env.BUILDKITE_BUILD_NUMBER, 10),
build_url: process.env.BUILDKITE_BUILD_URL,
Expand All @@ -16,15 +35,6 @@ export const run = async (): Promise<void> => {
suite: [],
};

if (process.env.DEBUG === "true") {
// display all environment variables except tokens
Object.keys(process.env)
.filter(key => !key.includes("TOKEN"))
.forEach(key => {
console.log(`${key}: ${process.env[key]}`);
});
}

const SLACK_TOKEN = process.env.SLACK_TOKEN;
const SLACK_CHANNEL = process.env.SLACK_CHANNEL;

Expand Down

0 comments on commit 90b4ae1

Please sign in to comment.