问题
*I am trying to run postman collections using Maven in Jenkins. I get below errors when the pipeline is run. I can run these locally with 'mvn clean verify' in intellij and all tests run successfully. I am bit lost as how to solve this issue and looking for some help.:-
[INFO] --- frontend-maven-plugin:1.6:npm (merge) @ ihtests ---
[INFO] Running 'npm run shipment-tests' in /var/jenkins/workspace/com.tcel_intests_merge/temp
[INFO]
[INFO] > postman-newman-jenkins@1.0.0 shipment-tests /var/jenkins/workspace/com.trakcel_ihtests_merge/temp
[INFO] > newman run test/postmancollection/AcceptValidRequest.postman_collection.json -e test/PostmanEnv/Test.postman_environment.json --reporters cli,junit --reporter-junit-export newman.xml
[INFO]
[ERROR] sh: /var/jenkins/workspace/com.tcel_intests_merge/temp/node_modules/.bin/newman: Permission denied
[ERROR] npm ERR! code ELIFECYCLE
[ERROR] npm ERR! errno 126
[ERROR] npm ERR! postman-newman-jenkins@1.0.0 shipment-tests: `newman run test/postmancollection/AcceptValidRequest.postman_collection.json -e test/PostmanEnv/Test.postman_environment.json --reporters cli,junit --reporter-junit-export newman.xml`
[ERROR] npm ERR! Exit status 126
[ERROR] npm ERR!
[ERROR] npm ERR! Failed at the postman-newman-jenkins@1.0.0 shipment-tests script.
POM:-
<profiles>
<profile>
<id>merge</id>
</profile>
</profiles>
<build>
<plugins>
<plugin>
<groupId>com.github.eirslett</groupId>
<artifactId>frontend-maven-plugin</artifactId>
<version>1.6</version>
<configuration>
<workingDirectory>.</workingDirectory>
<!-- where to install npm -->
<installDirectory>.</installDirectory>
</configuration>
<executions>
<execution>
<id>install-node-and-npm</id>
<goals>
<goal>install-node-and-npm</goal>
</goals>
<configuration>
<nodeVersion>v10.15.3</nodeVersion>
<npmVersion>6.14.8</npmVersion>
</configuration>
</execution>
<execution>
<id>npm install</id>
<goals>
<goal>npm</goal>
</goals>
<!-- Optional configuration which provides for running any npm command -->
<configuration>
<arguments>install</arguments>
</configuration>
</execution>
<execution>
<id>merge</id>
<goals>
<goal>npm</goal>
</goals>
<configuration>
<arguments>
**run shipment-tests**
</arguments>
</configuration>
<phase>generate-resources</phase>
</execution>
</executions>
</plugin>
</plugins>
</build>
Contents of Package.json:-
{
"name": "postman-newman-jenkins",
"version": "1.0.0",
"description": "Project for storing postman tests",
"main": "index.js",
"directories": {
"tests": "test/postmancollection"
},
"scripts": {
"shipment-tests": "newman run test/postmancollection/AcceptValidRequest.postman_collection.json -e test/PostmanEnv/Test.postman_environment.json --reporters cli,junit --reporter-junit-export newman.xml"
},
"repository": {
"type": "git",
"url": "git@gitlab.dev.com:test-automation/intests.git"
},
"author": "JJ",
"dependencies": {
"newman": "^5.2.0",
"npm": "^6.14.8"
}
}
Pipeline:-
pipeline {
agent {label '!master'}
}
stages {
stage('Run ih api tests') {
steps {
sh 'mvn clean verify -P merge'
}
}
}
}
来源:https://stackoverflow.com/questions/64406365/error-npm-err-errno-126-when-running-postman-collections-using-maven-in-jenkin