'Set' Collection Variables in Pre-Request causes an in error Jenkins because of Newman

Postman has released an update that allows users to set Collection Variables in the Pre-Request scripts. I have been using this new functionality in my Collection and it has successfully worked. When adding this collection to Jenkins, the job fails because Newman does not handle setting Collection Variables in the Pre-Request script.

For example, my Pre-Request script looks like this:
// username and email use sysdate + “@mailinator.com
const date = new Date();
partialUsername = date.getTime();
const username = “cubic” + partialUsername;
partialEmail = date.getTime();
const email = “cubicTest” + partialEmail + “@mailinator.com”;
pm.collectionVariables.set(‘username’, username);
pm.collectionVariables.set(‘email’, email);

In Jenkins, the error I am seeing is:

failure detail

  1. TypeError
    Cannot read property ‘set’ of undefined
    at prerequest-script
    inside “C2456099 - Create Account / Create Account”

Looks like Newman needs an update to allow this new functionality released by Postman.

Anyone have any ideas when that would be?

Hi @andysalazar, welcome to the community! :wave:

Can you check whether you’ve the latest newman version (4.5.5 as of today) running in the pipeline?

Hello Sivcan,

Yes, this worked! Thank you for replying to me question.

1 Like