I have a problem with run Jenkins job with additional parameters In my package.json I named a script name with some browser configs like:
"mobile": "npx wdio run ./config/wdio.mobile.conf.js"
I have got a config file with my mobile devices:
exports.config = {
...config,
...{
user: process.env.SAUCE_USERNAME,
key: process.env.SAUCE_ACCESS_KEY,
testobject_api_key: process.env.SAUCE_RDC_ACCESS_KEY,
region: 'eu',
specs: [
'./features/*'
],
maxInstances: 1,
capabilities: [{
deviceName: 'Samsung Galaxy S',
automationName: 'UiAutomator2',
platformName: 'Android',
idleTimeout: 180,
cacheId: new Date().getTime(),
noReset: true,
autoGrantPermissions: true,
orientation: 'PORTRAIT',
newCommandTimeout: 180,
build: 'test',
name: 'test',
maxInstances: 1,
}],
services: ['sauce'],
}
}
But instead of hardcoded strings with deviceName etc I want to use some parameters to set any device while running Jenkins job something like:
Additional problem:
How to manage running multiple devices? For example an array of devices at once. (30 devices).
I would appreciate your help
One way to do that is to manipulate env file
On Jenkins side:
echo DEVICE_NAME=${DEVICE_NAME} >> .env
On config side parametrize device capabilities like that:
deviceName: `${process.env.DEVICE_NAME}`
automationName: `${process.env.AUTOMATION_NAME}`
platformName: `${process.env.PLATFORM_NAME}`