# Newman command line integration with Jenkins

**URL:** <https://community.postman.com/t/newman-command-line-integration-with-jenkins/17195>\
**Category:** Help Hub\
**Tags:** newman-project, jenkins\
**Created:** [October 28, 2020, 5:44pm UTC](https://community.postman.com/t/newman-command-line-integration-with-jenkins/17195 "2020-10-28T17:44:54Z")\
**Posts on this page:** 14\
**Page:** 1

<div class="post-metadata">

**Author:** ![svarshney2311](https://avatars.discourse-cdn.com/v4/letter/s/e36b37/32.png) [@svarshney2311](https://community.postman.com/u/svarshney2311)\
**Post date:** [October 28, 2020, 5:44pm UTC](https://community.postman.com/t/newman-command-line-integration-with-jenkins/17195/1 "2020-10-28T17:44:54Z")

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

Hi,

Is there any way , can I pass test data from jenkins to API request body?  
something like this:

```auto
newman run https://www.getpostman.com/collections/XXXXXXXX -d TestData.json='{"parameter":[{"Authenticate": [{"msisdn": "%msisdn%","pin": "%pin%"}]}' --reporters cli

```

here I want msisdn and pin to be passed from Jenkins to postman testdata file,so that internally it will be passed to Postman request body.

Can we achieve this?

---

<div class="post-metadata">

**Author:** ![danny-dainton](https://sea2.discourse-cdn.com/getpostman/user_avatar/community.postman.com/danny-dainton/32/29401_2.png) [@danny-dainton](https://community.postman.com/u/danny-dainton)\
**Post date:** [October 29, 2020, 3:01pm UTC](https://community.postman.com/t/newman-command-line-integration-with-jenkins/17195/2 "2020-10-29T15:01:29Z")

</div>

Using the `-d` flag in the request would need to point to a datafile (JSON/CSV) that has been stored somewhere locally or a URL that returns the data in the correct format.

You could use either `--global-var` or `--env-var` to pass data from your Jenkins script into the Collection.

This for example, if the `{{foo}}` variable was used, it would resolve it to the `bar` value.

```auto
--global-var "foo=bar"

```

I don’t really know Jenkins very well so I’m not going to be able to give much advice here but you can do something basic to test it out:

```auto
--global-var "testing={"parameter":[{"Authenticate": [{"msisdn": "%msisdn%","pin": "%pin%"}]}"

```

I don’t really know your context behind those variables you’re using so you would need to experiment with that.

---

<div class="post-metadata">

**Author:** ![svarshney2311](https://avatars.discourse-cdn.com/v4/letter/s/e36b37/32.png) [@svarshney2311](https://community.postman.com/u/svarshney2311)\
**Post date:** [October 30, 2020, 2:53am UTC](https://community.postman.com/t/newman-command-line-integration-with-jenkins/17195/3 "2020-10-30T02:53:15Z")

</div>

Hi, I am passing below command  
newman run [https://www.getpostman.com/collections/XXXXXXXXXXXXX](https://www.getpostman.com/collections/XXXXXXXXXXXXX) -d /TestData/QA\_Regression\_TestData.json --global-var “msisdn=2332234444”

but msisdn value is not overriden by environment variable

msisdn is stored in TestData sheet file.

---

<div class="post-metadata">

**Author:** ![danny-dainton](https://sea2.discourse-cdn.com/getpostman/user_avatar/community.postman.com/danny-dainton/32/29401_2.png) [@danny-dainton](https://community.postman.com/u/danny-dainton)\
**Post date:** [October 30, 2020, 7:08am UTC](https://community.postman.com/t/newman-command-line-integration-with-jenkins/17195/4 "2020-10-30T07:08:29Z")

</div>

Is the same variable also being used in the datafile you’re using as well as being set as a global variable on the CLI?

> **[Using variables | Postman Learning Center](https://learning.postman.com/docs/sending-requests/variables/#variable-scopes)**
>
> Using variables: documentation for Postman, the collaboration platform for API development. Create better APIs—faster.

The Newman command alone is pretty meaningless here as that datafile could literally contain anything and the collection could be doing all sorts of things with the data.

Can you expand on all the details of what’s going on and explain what each variable is and where its being used.

Also, you’re using the public URL to reference the collection file, just ensure that if you have made a change in the collection, you need to update the link for those changes to be known to Newman.

---

<div class="post-metadata">

**Author:** ![svarshney2311](https://avatars.discourse-cdn.com/v4/letter/s/e36b37/32.png) [@svarshney2311](https://community.postman.com/u/svarshney2311)\
**Post date:** [October 30, 2020, 8:29pm UTC](https://community.postman.com/t/newman-command-line-integration-with-jenkins/17195/5 "2020-10-30T20:29:59Z")

</div>

Hi Danny,

I am getting data (?e.g msisdn ) from json file.here is acommand which Iam using to get data:  
let idArray = pm.iterationData.get(“PhoneNumbers\_Available”)  
and than  
var id = idArray[counter];  
pm.environment.set(“msisdn”,id.msisdn);

now I am trying to pass the data from command line instead of data file. and passing --global-var or --env-var, but its not picking from cli

---

<div class="post-metadata">

**Author:** ![danny-dainton](https://sea2.discourse-cdn.com/getpostman/user_avatar/community.postman.com/danny-dainton/32/29401_2.png) [@danny-dainton](https://community.postman.com/u/danny-dainton)\
**Post date:** [October 30, 2020, 9:38pm UTC](https://community.postman.com/t/newman-command-line-integration-with-jenkins/17195/6 "2020-10-30T21:38:07Z")

</div>

I’m not going to lie, I have no idea what you’re trying to do here from what you’re saying. 😬

The random pieces of code don’t really make any sense in isolation.

Can you DM me the collection and the datafile so I can see what you have got in front of you. Without those it’s going to be tough to help here.

---

<div class="post-metadata">

**Author:** ![svarshney2311](https://avatars.discourse-cdn.com/v4/letter/s/e36b37/32.png) [@svarshney2311](https://community.postman.com/u/svarshney2311)\
**Post date:** [November 1, 2020, 5:02pm UTC](https://community.postman.com/t/newman-command-line-integration-with-jenkins/17195/7 "2020-11-01T17:02:44Z")

</div>

Thanks for your idea.

I just made one change in my scripts. instead of passing pm. environment.set, I passed pm.globals.set in pre request; and in cli, i passed --env-var. This one worked for me.

---

<div class="post-metadata">

**Author:** ![svarshney2311](https://avatars.discourse-cdn.com/v4/letter/s/e36b37/32.png) [@svarshney2311](https://community.postman.com/u/svarshney2311)\
**Post date:** [November 2, 2020, 2:01am UTC](https://community.postman.com/t/newman-command-line-integration-with-jenkins/17195/8 "2020-11-02T02:01:26Z")

</div>

I got another two issues. Could you please check.

Issue1) I want to pass values from environment variable, if I dont pass from environment variable(–env-var) , this should be picked from the already set value from postman.  
Actual:  
everytime its picking from --env-var. If I dont pass any value in --env-var, its passing as null or empty.

Issue2) I have key values in “” ,but its skipping double quotes.inLast screensho, deviceprice and monthlybillprice is without double quotes in report , but I passed request as:  
{“devicePrice”: 100,“monthlyBillPrice”: 800}

Here is my request and CLI:

 ![image](https://us1.discourse-cdn.com/getpostman/original/3X/e/d/edda6f5c55337fe852aec818d4617eff280fb183.png)  
 ![image](https://us1.discourse-cdn.com/getpostman/original/3X/4/f/4ff12873cd49d78258b807c9b9d8ff59f9a26972.png)  
 ![image](https://us1.discourse-cdn.com/getpostman/original/3X/a/e/aea62b17fd6886edc715adb1a0e18c2897e0feb9.png)

newman run [https://www.getpostman.com/collections/XXXXXXXXXXX](https://www.getpostman.com/collections/XXXXXXXXXXX) --env-var “msisdn=123456789” --env-var “request={“devicePrice”: 100,“monthlyBillPrice”: 800}” --reporters htmlextra,cli --reporter-htmlextra-export Results/report.html --reporter-htmlextra-template Report/MyReport.hbs

Here in report devicePrice and monthlyBillPrice are without double quotes but I passed double quotes in command line.

 ![image](https://us1.discourse-cdn.com/getpostman/original/3X/3/d/3dd8d69ab3d1e2a118a904e5ac1d451133015c7c.png)

---

<div class="post-metadata">

**Author:** ![svarshney2311](https://avatars.discourse-cdn.com/v4/letter/s/e36b37/32.png) [@svarshney2311](https://community.postman.com/u/svarshney2311)\
**Post date:** [November 9, 2020, 10:44pm UTC](https://community.postman.com/t/newman-command-line-integration-with-jenkins/17195/9 "2020-11-09T22:44:58Z")

</div>

Hi Danny,

Is there any update on issue2 . this is critical to me and holding some of my testing.  
I have handled issue 1 in shell script, so we can ignore issue 1 now.

Thanks,  
Shailendra

---

<div class="post-metadata">

**Author:** ![danny-dainton](https://sea2.discourse-cdn.com/getpostman/user_avatar/community.postman.com/danny-dainton/32/29401_2.png) [@danny-dainton](https://community.postman.com/u/danny-dainton)\
**Post date:** [November 9, 2020, 11:05pm UTC](https://community.postman.com/t/newman-command-line-integration-with-jenkins/17195/10 "2020-11-09T23:05:22Z")

</div>

Is there an expectation that I’m supposed to be doing something here?

It’s not something I’ve even looked at since responding nearly 2 weeks ago.

---

<div class="post-metadata">

**Author:** ![svarshney2311](https://avatars.discourse-cdn.com/v4/letter/s/e36b37/32.png) [@svarshney2311](https://community.postman.com/u/svarshney2311)\
**Post date:** [November 9, 2020, 11:18pm UTC](https://community.postman.com/t/newman-command-line-integration-with-jenkins/17195/11 "2020-11-09T23:18:36Z")

</div>

> [@svarshney2311](#):
>
> Issue2) I have key values in “” ,but its skipping double quotes.inLast screensho, deviceprice and monthlybillprice is without double quotes in report , but I passed request as:  
> {“devicePrice”: 100,“monthlyBillPrice”: 800}

I have issue while passing environment variable.Please see issue 2 above.

---

<div class="post-metadata">

**Author:** ![danny-dainton](https://sea2.discourse-cdn.com/getpostman/user_avatar/community.postman.com/danny-dainton/32/29401_2.png) [@danny-dainton](https://community.postman.com/u/danny-dainton)\
**Post date:** [November 10, 2020, 3:13am UTC](https://community.postman.com/t/newman-command-line-integration-with-jenkins/17195/12 "2020-11-10T03:13:25Z")

</div>

Have you tried wrapping it in single quotes so it doesn’t think you’re opening and closing the double quotes:

```auto
--env-var 'request={"device Price": 100, "monthly Bill Price": 800}' 

```

 ![image](https://us1.discourse-cdn.com/getpostman/original/3X/e/a/ea8e3a1510c032fba6d135da96220c21bc65737c.png)

 ![Screenshot 2020-11-10 at 09.52.45](https://us1.discourse-cdn.com/getpostman/original/3X/d/a/da31cdefbefe6692ab5eb5f6081234318ac4bbfe.png)

This isn’t really a Postman problem, it’s the way certain characters (single or double quotes ) are handled by your OS when adding them in a CLI.

---

<div class="post-metadata">

**Author:** ![svarshney2311](https://avatars.discourse-cdn.com/v4/letter/s/e36b37/32.png) [@svarshney2311](https://community.postman.com/u/svarshney2311)\
**Post date:** [November 13, 2020, 7:22pm UTC](https://community.postman.com/t/newman-command-line-integration-with-jenkins/17195/13 "2020-11-13T19:22:34Z")

</div>

I tried this --env-var ‘request=$request’ and my Newman script is in shell script.  
OS: Windows10  
request={“isCreditCardSaved”:8} sh invoke\_digital\_api\_tests.sh

but I got below in request:

 ![image](https://us1.discourse-cdn.com/getpostman/original/3X/7/2/7244f35377d300564128aa4f3bf8cdb68c5cb55e.png)

---

<div class="post-metadata">

**Author:** ![svarshney2311](https://avatars.discourse-cdn.com/v4/letter/s/e36b37/32.png) [@svarshney2311](https://community.postman.com/u/svarshney2311)\
**Post date:** [November 13, 2020, 7:29pm UTC](https://community.postman.com/t/newman-command-line-integration-with-jenkins/17195/14 "2020-11-13T19:29:25Z")

</div>

Sorry…–env-var “request=$request’”  
request=’{“isCreditCardSaved”:8}’ sh invoke\_digital\_api\_tests.sh

above trick worked for me . Thanks.  
We can close this now
