相关疑难解决方法(0)

Jenkins管道脚本中的try-catch块

我正在尝试使用以下代码来执行构建,最后,在构建成功时执行构建后操作.不过,我得到一个MultipleCompilationErrorsException,说我的try块不是有效的section定义.请帮助,我尝试了很多重组块但似乎无法解决问题.

#!/usr/bin/env groovy

pipeline{

agent any 
    try {
        stages{
            stage("Parallel 1") {
                steps {
                    parallel (
                       'firstTask' : { 
                            build( "DSL-Controll-Demo-Fibonacci-1" )
                        },
                        'secondTask' : { 
                            build( "DSL-Controll-Demo-Fibonacci-2" )
                        }
                    )
                }
            }
            stage("Feature") {
                steps {
                        build( "DSL-Controll-Demo-Fibonacci-5" )
                        build( "DSL-Controll-Demo-Fibonacci-6" )
                }
            }
            stage("Parallel 2") {
                steps{
                    parallel (
                        "thirdTask" : { 
                            build( "DSL-Controll-Demo-Fibonacci-3" )
                        },
                        "forthTask" : { 
                            build( "DSL-Controll-Demo-Fibonacci-4" )
                        }
                    )
                }
            }
        }
    }   

    catch(all) {
        currentBuild.result = 'FAILURE'
    }   

    if(currentBuild.result != 'FAILURE') { …
Run Code Online (Sandbox Code Playgroud)

groovy try-catch jenkins jenkins-pipeline

15
推荐指数
5
解决办法
6万
查看次数

标签 统计

groovy ×1

jenkins ×1

jenkins-pipeline ×1

try-catch ×1