Jenkins 管道插件如何运行并行任务

标签 jenkins jenkins-pipeline

Jenkins 管道插件如何运行并行任务

我是 jenkins 的初学者,我想使用管道插件在 jenkins 的可用从节点上并行启动一些任务。

我安装了管道插件并在管道内联脚本部分添加了下面的内容。

grovvy script : 
    parallel firstBranch: {
        node('master'){
            echo 'firstBranch'
        }
    }, 
    secondBranch: {
        node('slave1'){
            echo 'secondBranch'
        }
    }

注意 : master 和 slave1 是我的节点

理想情况下 firstBranch 和 secondBranch 是什么????

控制台输出:

Started by user anonymous [Pipeline] parallel [Pipeline] [firstBranch] { (Branch: firstBranch) [Pipeline] [secondBranch] { (Branch: secondBranch) [Pipeline] [firstBranch] node [firstBranch] Running on master in /scratch/gnithyan/.hudson/workspace/pipeline_test
[Pipeline] [secondBranch] node
[Pipeline] [secondBranch] // node
[Pipeline] [secondBranch] }
[secondBranch] Failed in branch secondBranch
[Pipeline] [firstBranch] {
[Pipeline] [firstBranch] echo
[firstBranch] firstBranch
[Pipeline] [firstBranch] }
[Pipeline] [firstBranch] // node
[Pipeline] [firstBranch] }
[Pipeline] // parallel
[Pipeline] End of Pipeline

java.lang.IllegalStateException: cannot start writing logs to a finished node org.jenkinsci.plugins.workflow.cps.nodes.StepStartNode[id=8] at org.jenkinsci.plugins.workflow.support.actions.LogActionImpl.(LogActionImpl.java:110) at org.jenkinsci.plugins.workflow.support.actions.LogActionImpl.stream(LogActionImpl.java:81) at org.jenkinsci.plugins.workflow.support.DefaultStepContext.get(DefaultStepContext.java:73) at org.jenkinsci.plugins.workflow.steps.StepDescriptor.checkContextAvailability(StepDescriptor.java:252) at org.jenkinsci.plugins.workflow.cps.DSL.invokeStep(DSL.java:179) at org.jenkinsci.plugins.workflow.cps.DSL.invokeMethod(DSL.java:126) at org.jenkinsci.plugins.workflow.cps.CpsScript.invokeMethod(CpsScript.java:108) at groovy.lang.GroovyObject$invokeMethod$0.call(Unknown Source) at org.codehaus.groovy.runtime.callsite.CallSiteArray.defaultCall(CallSiteArray.java:48)

最佳答案

我也有同样的问题。也许我找到了依赖插件:
https://wiki.jenkins-ci.org/display/JENKINS/Pipeline+Supporting+APIs+Plugin
请参阅版本 2.10 的发行说明
在 2.9 中并行处理某些步骤的日志处理回归。

是的,更新插件有效!

关于Jenkins 管道插件如何运行并行任务,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/40151768/

相关文章:

java - Openshift + Jenkins在构建期间无法分配内存

java - 如何将变量设置为 pom.xml 中的数据库密码

angularjs - 无法使用 Jenkins 构建 Angular 项目

ios - Jenkins iOS faSTLane 构建 : Could not find 'bundler'

git - 从 Jenkins 管道捕获 shell 脚本输出

jenkins-pipeline - 当管道名称以交付结束时,如何跳过 Jenkinsfile 管道中的一个阶段?

ubuntu - 打开的文件太多错误!安装很多插件后无法打开 Jenkins

jenkins - 如何将 Jenkins 凭据传递给 gradle?

jenkins - Jenkins Pipeline访问环境变量

jenkins - jenkins 多分支管道中的分支索引会触发额外的构建,该构建已由 poll SCM 构建