From 07efa1813473bd115c687138987643c62b0f3a47 Mon Sep 17 00:00:00 2001 From: maguire-arman Date: Tue, 15 Jul 2025 11:29:49 -0400 Subject: [PATCH] Loads environment variables in Docker containers Ensures environment variables defined in the env file are loaded into the Docker containers used for Playwright tests. This is achieved by sourcing the env file within the `docker create` command. Removes the unnecessary CI=true environment variable setting. --- Dockerfile.playwright | 2 -- temp/playwright-test.yml | 15 +++++++++++---- 2 files changed, 11 insertions(+), 6 deletions(-) diff --git a/Dockerfile.playwright b/Dockerfile.playwright index 0e3543e68..0f5f6af3e 100644 --- a/Dockerfile.playwright +++ b/Dockerfile.playwright @@ -1,5 +1,3 @@ -FROM node:20 - FROM mcr.microsoft.com/playwright:v1.48.0-noble # Set the working directory in the container diff --git a/temp/playwright-test.yml b/temp/playwright-test.yml index f0984bfb8..53e8d296a 100644 --- a/temp/playwright-test.yml +++ b/temp/playwright-test.yml @@ -162,7 +162,6 @@ jobs: TOTAL_SHARDS=${{ parameters.totalShards }} container_id=$(docker create \ --ipc=host \ - --env CI=true \ --env-file "${{ parameters.envFileName }}" \ ${{ parameters.dockerImageName }}:${{ parameters.imageTag }} \ npx concurrently -k -n 'server,playwright' \ @@ -177,12 +176,17 @@ jobs: export SERVE_PATH="${{ parameters.npmServePath }}" export SHARD_NUMBER=$(shardNumber) export TOTAL_SHARDS=${{ parameters.totalShards }} + export ENV_FILE="${{ parameters.envFileName }}" container_id=$(docker create \ --ipc=host \ - --env CI=true \ --env-file "${{ parameters.envFileName }}" \ ${{ parameters.dockerImageName }}:${{ parameters.imageTag }} \ - bash -c "PLAYWRIGHT_BLOB_OUTPUT_DIR='/app/blob-report' npx --prefix $PLAYWRIGHT_PATH playwright test $PLAYWRIGHT_PATH --config=$PLAYWRIGHT_PATH/playwright.config.ts --shard=$SHARD_NUMBER/$TOTAL_SHARDS --reporter=list,blob $FILTER" \ + bash -c " + set -a + source $ENV_FILE + set +a + PLAYWRIGHT_BLOB_OUTPUT_DIR='/app/blob-report' npx --prefix $PLAYWRIGHT_PATH playwright test $PLAYWRIGHT_PATH --config=$PLAYWRIGHT_PATH/playwright.config.ts --shard=$SHARD_NUMBER/$TOTAL_SHARDS --reporter=list,blob $FILTER + " \ ) fi # Start container and stream logs @@ -250,12 +254,15 @@ jobs: export JIRA_CARD_NUMBER="$JIRA_CARD_NUMBER" + export ENV_FILE="${{ parameters.envFileName }}" container_id=$(docker create \ --ipc=host \ - --env CI=true \ --env-file "${{ parameters.envFileName }}" \ ${{ parameters.dockerImageName }}:${{ parameters.imageTag }} \ bash -c " + set -a + source $ENV_FILE + set +a echo 'Moving Playwright reports out of subfolders...' find ./playwright-reports/ -mindepth 2 -type f -exec mv {} ./playwright-reports/ \; echo 'Value of JIRA_CARD_NUMBER in bash -c command: $JIRA_CARD_NUMBER'