如何使用詹金斯并行执行2个纽曼任务?

时间:2019-01-17 11:11:19

标签: jenkins

How to Execute  this below code in paralley.. please help iam new to jenkins.

parallel firstBranch: {
node{
    newman run xyz.json
    }
},
secondBranch:{
    node{
      newman run xyz123.json
    }

}
},
failFast: true|false

为此,我在错误以下得到提示: 另外:

org.jenkinsci.plugins.workflow.steps.FlowInterruptedException
        at org.jenkinsci.plugins.workflow.cps.CpsBodyExecution.cancel(CpsBodyExecution.java:244)
        at org.jenkinsci.plugins.workflow.steps.BodyExecution.cancel(BodyExecution.java:76)
        at org.jenkinsci.plugins.workflow.cps.steps.ParallelStepExecution.stop(ParallelStepExecution.java:67)
        at org.jenkinsci.plugins.workflow.cps.steps.ParallelStep$ResultHandler$Callback.checkAllDone(ParallelStep.java:147)
        at org.jenkinsci.plugins.workflow.cps.steps.ParallelStep$ResultHandler$Callback.onFailure(ParallelStep.java:134)
        at org.jenkinsci.plugins.workflow.cps.CpsBodyExecution$FailureAdapter.receive(CpsBodyExecution.java:349)
        at com.cloudbees.groovy.cps.impl.ThrowBlock$1.receive(ThrowBlock.java:68)

1 个答案:

答案 0 :(得分:0)

尝试Jenkins文档实例,单击下面的链接:

Parallel stages with Declarative Pipeline 1.2

与詹金斯结交新朋友很容易

  1. 安装nodeJS和npm
  2. 通过`npm install -g newman
  3. 安装newman
  4. 创建json文件newman-test: { "name": "postman-newman-jenkins", "version": "1.0", "description": "Project postman test", "directories": { "test": "tests" }, "scripts": { "api-tests-production": "newman run postman_collection.json --reporters cli,html --reporter-html-export ${Environment}-$BUILD_NUMBER-newman.html --reporter-html-template template.hbs }, "author": "me or you", "dependencies": { "newman": "^3.5.2" } }
  5. 在詹金斯身边

     try {
    
              sh 'npm install'
              sh 'npm run newman-test'
    
     }
              catch (Exception err) {
                  currentBuild.result = 'UNSTABLE'
      }
    
  6. 存档报告

    archiveArtifacts'jenkins / $ {Environment}-$ BUILD_NUMBER-newman.html'

最后,您可以格式化此代码以遵守声明性管道代码