Passing the postman environment variable to Jenkins script

Your question may already have an answer on the community forum. Please search for related topics, and then read through the guidelines 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

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).

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

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.