File upload with newman and the postman API

My question:
We have a collection of postman tests which are run by Jenkins in a docker container. The tests are downloaded from the postman API and then executed by newman. I have added a test that uploads a file but newman fails to find the file in the docker container. This test works in newman run from on my desktop because the file itself is in the expected location on the desktop. I have the file also in the container but it is in a different location on disk.

Is there a way to save the file reference to have a relative path rather than an absolute one so it will work wherever it is executed from?

Can I solve this problem without having to download and modify the json of the postman tests on each test run?

I specifically want to keep the functionality of providing a postman api endpoint for the test to newman at the start of each test run.

Details (like screenshots):
This is the newman error when the test is run from Jenkins

What the test looks like in postman

I’ve already tried:
For all of the similar questions I have managed to find, none of them appear to cover the case where the tests are referenced directly from the postman API. Those questions appear to have the json of their tests in manual source control and are manipulating the json directly which seems less elegant and would change the whole setup of our testing.

Hey, thanks for your patience. A workaround for storing a relative path would be specifying a working directory under Settings. You can then ensure that the file inside your container has the same relative path from where the collection exists.
Let us know if you face any issues with the solution.

Thanks for your reply

I do face problems with this solution and had previously looked into working directories.

I am developing the tests on windows in postman and I am executing the tests with newman on a Linux container. Linux and Windows have completely different file systems and require different working directories. Is there a way to specify to newman what the working directory is at runtime so I can configure it for the container? If not this solution will not work for me.

1 Like