Integrate Postman test scripts with Jenkins build server

I downloaded the POSTMAN Chrome app to test some web APIs in a local local environment.

In addition, I downloaded the Newman command-line utility for Postman.

See https://www.getpostman.com/docs/newman_intro for more details.

So, the Postman application works fine, and the cmd-line utility also works.

However, as soon as I integrate it with the Jenkins test server, the tests do not work.

The main problem is that it cannot start Newman .

At the standard cmd prompt, I can successfully run the Newman test script as:

  newman -c API-Collection.json -n 3 

executed n times.

from the command line

And in the Jenkins Build Server GUI, I add a script construct in the "Execute Shell" section.

enter image description here

But he does not find Newman , as this build error shows:

  FailedConsole Output Started by user anonymous Building in workspace C:\Program Files (x86)\Jenkins\workspace\Web Api Test1 (Team Gecko) [Web Api Test1 (Team Gecko)] $ "C:\Program Files\bin\sh.exe" -xe C:\Windows\TEMP\hudson2522506155962538386.sh + newman -c C:\Users\robertjm\Documents\POSTMAN Files\Workbench-API-Collection.json -n 3 -y 1000 --exitCode 1 -o output.json -H output.html C:\Windows\TEMP\hudson2522506155962538386.sh: newman: command not found Build step 'Execute shell' marked build as failure Finished: FAILURE 

If someone can help me in solving this problem, I would appreciate it.

thanks bob

+7
jenkins postman
source share
3 answers

The final decision was:

1) Add the “Run Windows Command Command” assembly step and add the two lines below:

2) change dir to newman \ bin:

  cd \Users\bob\appdata\roaming\npm\node_modules\newman\bin 

3) run node newman , and not just try starting newman

  node newman -c "C:\\Users\\bob\\Documents\\POSTMAN Files\\Workbench-API-Collection.json" 

Two complex parts:

1) starting a new user in this way newman -c myCollection.json did not work, because Jenkins was not able to resolve this node module, as it would in the Win cmd direct prompt.

2) Trying to find the Newman module was difficult because it is hidden inside the %appdata% folder (i.e. c: \ users \ bob \ $ appdata $).

I hope this helps someone in the future.

good luck.

+7
source share

Run the “what a new person” command in the prommpt command. It will return something like - / C / Users / user1 / AppData / Roaming / NMP / Newman

Now use the fully covered path returned by the above command in the command line field of the Jenkins window -

c: / Users / user1 / AppData / Roaming / npm / newman -c demo.postman_collection.json

+2
source share

Postman Integration with Jenkins on a Windows Machine

Step # 1: Download Jenkins to the local Windows machine.

URL for Jenkins download: - https://jenkins.io/download/ After a successful download, enter: - http: // localhost: 8080 Step # 2: Enter the name of the project and click "Freestyle Project" and save it. screen 1

Step # 3: PostmanScriptTest2 is created and when managing source code> build> click the execute batch command to execute. screen 2

Step # 3: enter a command at the Execute Windows command prompt

C: \ Users \ ashish \ AppData \ Roaming \ npm \ newman run https://www.getpostman.com/collections/d231549a4assc77abcdbaf9c674

Click "Save" and apply. screen3

Step # 4: Go to the Jenkins homepage and click “Manage Jenkins”

screen4 Step # 5: Under Jenkins, click on system setup.

screen5

Step # 6: Under Global Properties> check your environment variables and enter

Name - PATH

Value - C: \ Program Files \ Nodejs screen 6

Step # 7: In the Shell command prompt, enter the shell executable C: \ Windows \ System32 \ cmd.exe and click "Save" and apply.

screen7

+2
source share

All Articles