# Passing the postman environment variable to Jenkins script

**URL:** <https://community.postman.com/t/passing-the-postman-environment-variable-to-jenkins-script/40839>\
**Category:** Help Hub\
**Tags:** newman-project, variables, jenkins\
**Created:** [November 7, 2022, 10:39am UTC](https://community.postman.com/t/passing-the-postman-environment-variable-to-jenkins-script/40839 "2022-11-07T10:39:24Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![AbhilashMT](https://sea2.discourse-cdn.com/getpostman/user_avatar/community.postman.com/abhilashmt/32/13835_2.png) [@AbhilashMT](https://community.postman.com/u/AbhilashMT)\
**Post date:** [November 7, 2022, 10:39am UTC](https://community.postman.com/t/passing-the-postman-environment-variable-to-jenkins-script/40839/1 "2022-11-07T10:39:24Z")

</div>

> **Archived topic — this may be out of date.**  
> Newman has been replaced by the **[Postman CLI](https://learning.postman.com/docs/postman-cli/postman-cli-overview/)**, Postman’s official, signed command-line tool. It runs collections as Newman did, and also lints API specs, runs mocks and monitors, and syncs local files with Postman from your terminal, CI/CD pipeline or coding agent.  
> Working with an AI coding agent? The [Postman plugin](https://github.com/postmanlabs/postman-plugin) lets agents in Claude Code, Cursor, Codex and others design, mock, test and ship APIs with Postman.  
> For current help, see the [Postman docs](https://learning.postman.com/docs/), try the free [Postman tools](https://www.postman.com/tools) (no account needed), or join us on [Discord](https://discord.gg/58aNNsRBGR).

**Your question may already have an answer on the community forum. Please search for related topics, and then read through the [guidelines](https://community.postman.com/t/about-the-just-getting-started-category/37) before creating a new topic.**

_My question_:  
How can we pass the postman collectionVariable to jenkins script

_Details (like screenshots)_:  
I am running a jenkins pipeline where in the first step im running the postman collection using newman, in the second step i need to send a mail to the team with the failure details if any. I could store the details into a collection variable during the execution, but how can i pass this variable to the second step in the jenkins pipeline where im mailing this details using a shell script

---

<div class="post-metadata">

**Author:** ![michaelderekjones](https://sea2.discourse-cdn.com/getpostman/user_avatar/community.postman.com/michaelderekjones/32/14819_2.png) [@michaelderekjones](https://community.postman.com/u/michaelderekjones)\
**Post date:** [November 7, 2022, 12:21pm UTC](https://community.postman.com/t/passing-the-postman-environment-variable-to-jenkins-script/40839/2 "2022-11-07T12:21:20Z")

</div>

You shouldn’t need to do anything in Postman.

There should be options in Jenkins for who gets emailed when a job completes. Pretty sure there are separate options for failures, so you can target the emails more granularly.

Haven’t used Jenkins for years, but this is how most continuous integration tools work. This is all configured in the job.

You need to make sure the job is picking up the Postman report and including it in the results. You shouldn’t need to mail those results. It should just tell you there are failures, and then provide a link to the results in Jenkins. (I think you can also include the report though, but as mentioned, I haven’t used Jenkins for a while or have access to check).

---

<div class="post-metadata">

**Author:** ![AbhilashMT](https://sea2.discourse-cdn.com/getpostman/user_avatar/community.postman.com/abhilashmt/32/13835_2.png) [@AbhilashMT](https://community.postman.com/u/AbhilashMT)\
**Post date:** [November 8, 2022, 9:46am UTC](https://community.postman.com/t/passing-the-postman-environment-variable-to-jenkins-script/40839/3 "2022-11-08T09:46:41Z")

</div>

In jenkins we have the option, but my question is how to pass the data in a variable to the scripts outside postman/newman  
for example, i have a collectionVariable iCount, which holds the total count of requests passed in my collection, after running this collection using newman in jenkins, i want to pass this number to another script which send the mail. So how can i access iCount variable from my second script

---

<div class="post-metadata">

**Author:** ![michaelderekjones](https://sea2.discourse-cdn.com/getpostman/user_avatar/community.postman.com/michaelderekjones/32/14819_2.png) [@michaelderekjones](https://community.postman.com/u/michaelderekjones)\
**Post date:** [November 9, 2022, 10:19am UTC](https://community.postman.com/t/passing-the-postman-environment-variable-to-jenkins-script/40839/4 "2022-11-09T10:19:05Z")

</div>

I don’t know if that is possible.

It sounds like the standard reports aren’t giving you the information you need.

Have a look at HTMLExtra which the developer has provided more functionality that might meet your requirement.
