In the previous blog, I wrote about using newman to generate postman. Now let's see how to deploy newman to Jenkins.
Since my test environment has already installed Jenkins and node, I won't go into details.
This blog mainly explains how to execute the newman command with Jenkins
1. Install Jenkins in the Linux environment
Here is a link
to other hotspots to install Jenkins. Reference link: https://blog.csdn.net/zjh_746140129/article/details/80835866
Two, install node.js in the linux environment
Reference link https://blog.csdn.net/sinat_37390744/article/details/77413673
running
node -v
To see if the installation is successful
Three, install newman
Because newman is a nodejs library launched by Postman, nodejs must be installed to run it, and newman can also be installed directly with npm
npm install -g newman
As shown in the figure below, the installed version of newman will appear after the installation, and the path where the installation is located. The
installed newman will
run in the folder where npm is located.
newman -v
To check if the installation is successful,
create a soft connection for newman
ln -s /var/lib/jenkins/env/node-v10.4.1-linux-x64/bin/newman /usr/bin/newman
Install html
npm install -g newman-reporter-html
Fourth, export the collection file from postman
Click the three dots on the right side of the use case set and
click Export
Five, run newman directly in linux
Put the exported json file into the Linux environment, including use cases and environment variables.
Execution
newman run 1.json -g env.json
The result is as shown in the figure below.
Note : It depends on which path the exported json file is placed in, and the running path must be correct. I put it in the root directory and run it under the root directory.
Generate html file
newman run 1.json -g env.json -r html
The generated html file is in the newman folder in the same directory
Six, run the script in Jenkins
Open Jenkins to
create a free-style project
, select Execute shell
in the build, and enter in the command
cd /
newman run 1.json -g env.json
In fact, just in command here linux operating environment as
Click Save
to enter the project, click Bulid Now
I encountered a problem during the execution of
that has been given in Jenkins Lane: / usr / bin / env: node: No such file or directory
This the problem is a result of the newman script because the top of the node position
should change the path node where files are located
at this time to go perform Jenkins project
will succeed you, as shown below
each time very happy and all learning experiences encountered Write the error on the blog and share it with everyone~ The
next step is to configure Jenkins to automatically send the test report email