@ola100 So I had to think about this a bit as I am sure there are a few ways you can accomplish this.
Depending on what you are looking to do exactly I would say you would just need to loop though things.
So here is an example of a bash script I have that does something like that:
#!/usr/bin/env bash
# Loop though each collection in the folder.
for filename in src/tests/*.json; do
newman run ${filename} \
--environment "configs/${1}.test.json" \
--verbose \
--disable-unicode \
--color on \
--delay-request 100
done
So what I am doing here is just doing a for
loop against a directory, that contains my collections.
There is also a parameter I am passing in here as well. ${1}
is the name of the environment I am running it against, I have different environment templates for each supported env I want to run against.
This is good practice if you plan to execute in more than a single env as then you wont require multiple scripts, one for each env.
So from this you can add in other things to the for
loop if you wanted. Like if you wanted to kick off a few runs at once or call something else.
Before you do this though you will prob want to have something in your Jenkins build job that calls the Postman API to get the collections you want and place them in a specific folder. You can do this by simply adding in Execute Shell
commands in your Jenkins job.
So a quick and dirty way to me would be to add in an execute shell command to get your collection:
curl -X GET \
https://api.getpostman.com/collections/394625-00000000-0000-0000-0000-000000000000 \
-H 'Cache-Control: no-cache' \
-H 'x-api-key: 1idxvfcbpanc4ydm9vdah28j8rwmm08n' > collection.json
Then get your env template, if you are using them:
curl -X GET \
https://api.getpostman.com/environments/394625-00000000-0000-0000-0000-000000000000 \
-H 'Cache-Control: no-cache' \
-H 'x-api-key: 1idxvfcbpanc4ydm9vdah28j8rwmm08n' > environment.json
You can do this for each collection you need to pull down or add some logic here to loop though and get them but this is just a quick walk though, so keeping some logic out of this.
Now you can run though the loop of collections as another execute shell command.
Not sure if this makes things any clearer but let me know and I will try to focus more on areas that you are having trouble with.