0

I want to run the script for two products product1 and product2 , the command contains string product1 product2 and runs script for two products as expected. The command looks like below on console:

pytest -v  -s --browser_name "MobileChrome" --env "Production" --product_name product1 product2 --disable-pytest-warnings

But the problem is the result file names are product1.xlsx and product2.xlsx respectively, but as I've passed ${product_Name}.xlsx in email attachment, Jenkins is trying to attach product1 product2.xlsx which doesn't exist. somehow I want to split the product name in attachment section and make it product1.xlsx and product2.xlsx so that I will get both files correctly attached in email.

enter image description here

enter image description here

in above image product name will become product1 product2 after passing below values in build with parameters:

enter image description here

$product_Name is a string parameter and can hold multiple values:

enter image description here

Gerold Broser
  • 14,080
  • 5
  • 48
  • 107

1 Answers1

0

Prior to sending mails you could try:

  • Project config → Post-build ActionsAdd post-build action ▼: Groovy PostbuildGroovy Script (not tested in real):
def myProducts = build.getEnvironment(listener).get('Product_Name')

// From Editable Email Notification → Attachments' inline help: 'The format is a comma separated list of Ant include file syntax.'

env.filesToBeAttached = ... // create a string "referenceData/product1.xlsx,referenceData/product2.xlsx" from myProducts here

// use it in Editable Email Notification → Attachments: $filesToBeAttached 

Hopefully the environment for the following Editable Email Notification is adapted accordingly. I'm not 100 % sure about that.

A trivial alternative would be to enter at build parameter Product_Name: referenceData/product1.xlsx,referenceData/product2.xlsx.

See also:

Gerold Broser
  • 14,080
  • 5
  • 48
  • 107