diff --git a/packages/artillery/lib/cli/common-flags.js b/packages/artillery/lib/cli/common-flags.js index d1461a0849..e01f597cd7 100644 --- a/packages/artillery/lib/cli/common-flags.js +++ b/packages/artillery/lib/cli/common-flags.js @@ -23,7 +23,8 @@ const CommonRunFlags = { description: 'Write a JSON report to file' }), dotenv: Flags.string({ - description: 'Path to a dotenv file to load environment variables from' + description: 'Path to a dotenv file to load environment variables from', + aliases: ['env-file'] }), variables: Flags.string({ char: 'v', diff --git a/packages/artillery/lib/platform/az/aci.js b/packages/artillery/lib/platform/az/aci.js index e9771b0cac..9112bd1fd7 100644 --- a/packages/artillery/lib/platform/az/aci.js +++ b/packages/artillery/lib/platform/az/aci.js @@ -20,6 +20,8 @@ const { IMAGE_VERSION } = require('../aws-ecs/legacy/constants'); const { regionNames } = require('./regions'); const path = require('path'); const { Timeout, sleep } = require('../aws-ecs/legacy/time'); +const dotenv = require('dotenv'); +const fs = require('node:fs'); class PlatformAzureACI { constructor(script, variablePayload, opts, platformOpts) { @@ -62,6 +64,8 @@ class PlatformAzureACI { this.memory = parseInt(platformOpts.platformConfig.memory, 10) || 8; this.region = platformOpts.platformConfig.region || 'eastus'; + this.extraEnvVars = {}; + if (!regionNames.includes(this.region)) { const err = new Error(`Invalid region: ${this.region}`); err.code = 'INVALID_REGION'; @@ -180,8 +184,13 @@ class PlatformAzureACI { } if (this.platformOpts.cliArgs.dotenv) { - this.artilleryArgs.push('--dotenv'); - this.artilleryArgs.push(path.basename(this.platformOpts.cliArgs.dotenv)); + const dotEnvPath = path.resolve( + process.cwd(), + this.platformOpts.cliArgs.dotenv + ); + const contents = fs.readFileSync(dotEnvPath); + const envVars = dotenv.parse(contents); + this.extraEnvVars = Object.assign({}, this.extraEnvVars, envVars); } if (this.platformOpts.cliArgs['scenario-name']) { @@ -519,6 +528,10 @@ class PlatformAzureACI { }); } + for (const [name, value] of Object.entries(this.extraEnvVars)) { + environmentVariables.push({ name, value }); + } + const containerGroup = { location: this.region, containers: [