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

**URL:** <https://community.postman.com/t/set-collection-variables-in-pre-request-causes-an-in-error-jenkins-because-of-newman/8384>\
**Category:** Help Hub\
**Tags:** newman-project\
**Created:** [October 15, 2019, 11:33pm UTC](https://community.postman.com/t/set-collection-variables-in-pre-request-causes-an-in-error-jenkins-because-of-newman/8384 "2019-10-15T23:33:55Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![andysalazar](https://avatars.discourse-cdn.com/v4/letter/a/4af34b/32.png) [@andysalazar](https://community.postman.com/u/andysalazar)\
**Post date:** [October 15, 2019, 11:33pm UTC](https://community.postman.com/t/set-collection-variables-in-pre-request-causes-an-in-error-jenkins-because-of-newman/8384/1 "2019-10-15T23:33:56Z")

</div>

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?

---

<div class="post-metadata">

**Author:** ![singhsivcan](https://sea2.discourse-cdn.com/getpostman/user_avatar/community.postman.com/singhsivcan/32/1595_2.png) [@singhsivcan](https://community.postman.com/u/singhsivcan)\
**Post date:** [October 16, 2019, 5:43am UTC](https://community.postman.com/t/set-collection-variables-in-pre-request-causes-an-in-error-jenkins-because-of-newman/8384/2 "2019-10-16T05:43:36Z")

</div>

Hi @andysalazar, welcome to the community! 👋

Can you check whether you’ve the [latest newman version (4.5.5 as of today)](https://www.npmjs.com/package/newman) running in the pipeline?

---

<div class="post-metadata">

**Author:** ![andysalazar](https://avatars.discourse-cdn.com/v4/letter/a/4af34b/32.png) [@andysalazar](https://community.postman.com/u/andysalazar)\
**Post date:** [October 16, 2019, 4:32pm UTC](https://community.postman.com/t/set-collection-variables-in-pre-request-causes-an-in-error-jenkins-because-of-newman/8384/3 "2019-10-16T16:32:02Z")

</div>

Hello Sivcan,

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