Setting the iteration data from collection not from newman

I have different collections on a branch that runs on jenkins, I won’t be able to access the server where jenkins is set up, so I won’t be able to alter the newman script on jenkins.
So far I’ve had to declare a new script per collection because I use an specfic iterationData per collection (I’m using the router logic) like this
newman run “postman-automation/tests/collection1” --iteration-data “postman-automation/testsRoutes/collection1-routes.json”
newman run “postman-automation/tests/collection2” --iteration-data “postman-automation/testsRoutes/collection2-routes.json”

I need to know if there’s a more scalable solution where I just set up the newman script where the tests are and the iteration data is, without having to specify which iterationData belongs to which collection on the newman script, that’s why I was wondering if it can be done from the collection:

to have something more like:
newman run “postman-automation/tests/" --iteration-data "postman-automation/testsRoutes/

Hi @gerardovanegas620 :wave:

Thanks for posting in community!

I understand what you would like to achieve is to batch process using newman command.

That would be a nice feature to have. I also found a similar feature request here.

You are encouraged to subscribe to this issue and please feel free to add your contexts and comments to weigh in.
Our product managers use that feedback to prioritize and add items to our development roadmap :grinning:

1 Like

Hi could you just confirm the difference between configure newman script , and alter newman script.

What is the existing script in jenkins , how are you triggering it for each collection

1 Like

This sounds like something you can be doing in the script itself, not really having anything to do with Postman.

Jenkins scripts are written in groovy, so you should be able to write a function to get the files in the working directory and pass them off to newman.

1 Like

Thanks!! That’s exactly what I’m trying to aim to, I just followed the thread on that feature.

1 Like

This is what I currently have to do, if you notice I run a new command batch per collection because each collection has it’s own iteration data so it doesn’t run a collection with an iteration file it doesn’t belong to (sorry if it’s in spanish)

yes but that will require me to add that directory on the jenkins script each time I add a new collection and a new iteration data file, I won’t have access to the server where jekins is stored, on my previous answer I enter what I’m trying to run locally, but the server where my collections are going to be run is not something I’ll have access to. So it’ll be dificult to request an script change every time I add a collection to the repository, if I end up creating 100 collections more, someone will have to modify that script a 100 times

you can run newman programtically also :slight_smile:

var newman = require('newman');{
   collection: '/path/to/collection.json',
   reporters: 'myreporter',
   reporter: {
     myreporter: {
       'option-name': 'option-value' // this is optional
}, function (err, summary) {
  if (err) { throw err; }'collection run complete!');

Newman-htmlreport using nodejs:

const newman = require('newman');{
    collection: './pathToFile/collection.json', // Collection URL from a public link or the Postman API can also be used
    reporters: ['htmlextra'],
    iterationCount: 1,
    reporter: {
        htmlextra: {
            // export: './report.html',
            // template: './template.hbs'
            // logs: true,
            // showOnlyFails: true,
            // noSyntaxHighlighting: true,
            // testPaging: true,
            // browserTitle: "My Newman report",
            // title: "My Newman Report",
            // titleSize: 4,
            // omitHeaders: true,
            // skipHeaders: "Authorization",
            // hideRequestBody: ["Login"],
            // hideResponseBody: ["Auth Request"],
            // showEnvironmentData: true,
            // skipEnvironmentVars: ["API_KEY"],
            // showGlobalData: true,
            // skipGlobalVars: ["API_TOKEN"],
            // skipSensitiveData: true,
            // showMarkdownLinks: true,
            // showFolderDescription: true,
            // timezone: "Australia/Sydney"

You can use this to pass your collection and iteration data directory and run in a forEach loop

1 Like

This sounds like very cool stuff, I’ll give it a shot, where shoud I set this up? on the prerequest script?

THis is pure nodejs code outside of postman.

Instead of running newman as a command line tool , we are running it as a library (nodejs module). Store the code as a javascript file eg script.js

and in jenkins you run it as node script.js

1 Like

Thanks man!!! it works like a charm!!!

The only missing thing here is, how can I add all the results into a single report? I know it’s too much asking lol, but I was wondering if you knew any solutions for this.

1 Like

Currently there is no way to combine reports

Single report is not posible as of now , as each collection run is viewed as individual runs . But as you are using newman as a library you can write your own code to combine all the reports and display as single html.