将job-dsl插件从1.50升级到1.72后没有方法错误的签名

时间:2019-05-27 14:01:23

标签: jenkins jenkins-plugins jenkins-job-dsl

我有一个使用jenkins插件的job-dsl工作。使用插件version 1.50,一切正常。升级到插件version 1.72后,作业执行报告了以下错误。

  

正在处理DSL脚本作业/custom_xyz.groovy错误:(BaseTests.groovy,   xxx行)没有方法签名:   javaposse.jobdsl.dsl.helpers.ScmContext.xyzPluginRepoBlock()是   适用于参数类型:()值:[]完成:FAILURE

使用job-dsl插件version 1.50尝试了相同的代码。它完成了,没有错误。

package lib

import groovy.json.JsonSlurper
import javaposse.jobdsl.dsl.Folder
import javaposse.jobdsl.dsl.Job
import javaposse.jobdsl.dsl.helpers.ScmContext
import javaposse.jobdsl.dsl.helpers.publisher.PublisherContext
import javaposse.jobdsl.dsl.helpers.step.StepContext

import static JenkinsUtils.getOrDefault

public class BaseTests {

    // Credential ID in Jenkins credential store
    .
    .
    .

    def context
    .
    .
    .

    def XYZPluginRepoBlock = { ScmContext context ->
        context.with {
            git {
                branch pluginBranch()
                remote {
                    url pluginRepo()
                    credentials 'jenkins-cred'
                }
                extensions {
                    relativeTargetDirectory 'XYZ'
                    wipeOutWorkspace
                    clean
                }
            }
        }
    }

    def extras = { Job context -> }

    public setupDeployJob(TemplateName, TemplatePath, nextJob = 'Undeploy') {
        context.with {
            def workdir = "$TemplatePath"
            job("${folderName()}/${TemplateName}${BASE_DEPLOY_JOB_NAME}") {
                jobDescription = "Deploys the $TemplateName Template using the XYZ Manager."
                description(jobDescription)

                if (!isMaster())
                    extras(delegate)

                environmentVariables {
                    env('DP', "${folderName()}-${TemplateName}${BASE_DEPLOY_JOB_NAME}-\$BUILD_NUMBER")
                }

                wrappers {
                    preBuildCleanup {
                        includePattern('results/**')
                        includePattern('outputs.properties')
                    }
                    credentialsBinding {
                        usernamePassword("xyz_USERNAME", "xyz_PASSWORD", xyzCred())
                    }
                }
                multiscm {
                    xyzPluginRepoBlock delegate
                    if (isMaster()) {
                        git {
                            branch 'master'
                            remote {
                                url 'http://<coderepourl>'
                            }
                            extensions {
                                wipeOutWorkspace
                                clean
                            }
                        }
                    }
                }
            }
        }
    }


    public setupUndeploy(jobTitle = 'Undeploy', nextJob = null) {
    .
    .
    .
    }
}

需要帮助以了解错误的含义以及如何解决该错误。

0 个答案:

没有答案