我是Jenkins的新手,我在eclipse I中创建了Maven + TestNG项目,我执行了示例测试用例以从POM.xml打印hello世界,并且运行良好。我也已经在GIT中推送了该项目。现在,我需要使用CI / CD的管道脚本从Jenkins执行该项目。
我在Jenkins管道选项卡中的Pipleline脚本下创建了,但是执行该脚本时出现错误。您能否指导我或提供教程链接,以获取Jenkins管道示例。
脚本如下:
node {
def mvnHome
stage('Preparation') { // for display purposes
// Get some code from a GitHub repository
git 'https://github.com/jitsolution19/RestAssured_Framework.git'
// Get the Maven tool.
// ** NOTE: This 'M3' Maven tool must be configured
// ** in the global configuration.
mvnHome = tool 'Maven'
}
stage('Build') {
// Run the maven build
if (isUnix()) {
sh "'${mvnHome}/bin/mvn' -Dmaven.test.failure.ignore clean package"
} else {
bat(/"${mvnHome}\bin\mvn" -Dmaven.test.failure.ignore clean package/)
}
}
stage('Test') {
//Perform test
echo 'Execute the script'
if (isUnix()) {
sh "'${mvnHome}/bin/mvn' -Dmaven.test.failure.ignore test"
} else {
bat(/"${mvnHome}\bin\mvn" -Dmaven.test.failure.ignore test/)
}
}
stage('Results') {
junit '**/target/surefire-reports/TEST-*.xml'
archive 'target/*.jar'
}
}