Jenkins将旧格式DSL转换为新版本

时间:2018-06-18 13:33:17

标签: jenkins jenkins-job-dsl

我从这个https://raw.githubusercontent.com/denschu/job-dsl-examples/master/job-dsl-example.groovy获取了DSL并尝试在我的Jenkins 2.107版本上创建作业。但它给出了丢失的标签错误。有关将此DSL转换为新版本的任何帮助吗?

Processing provided DSL script
ERROR: (script, line 10) No signature of method: javaposse.jobdsl.dsl.helpers.scm.GitContext.createTag() is applicable for argument types: (java.lang.Boolean) values: [false]

我正在使用的DSL。

def projectName = "deploy-application"

        freeStyleJob("${projectName}"){
        triggers { scm("*/5 * * * *") }
        scm {
            git {
                remote {
                    url("https://github.com/codecentric/spring-samples")
                }
                createTag(false)
            }
        }
        rootPOM("${projectName}/pom.xml")
        goals("clean package")
        wrappers {
            preBuildCleanup()
            release {
                preBuildSteps {
                    maven {
                        mavenInstallation("Maven 3.0.4")
                        rootPOM("${projectName}/pom.xml")
                        goals("build-helper:parse-version")
                        goals("versions:set")
                        property("newVersion", "\${parsedVersion.majorVersion}.\${parsedVersion.minorVersion}.\${parsedVersion.incrementalVersion}-\${BUILD_NUMBER}")
                    }
                }
                postSuccessfulBuildSteps {
                    maven {
                        rootPOM("${projectName}/pom.xml")
                        goals("deploy")
                    }
                    maven {
                        goals("scm:tag")
                    }
                    downstreamParameterized {
                        trigger("deploy-application") {
                            predefinedProp("STAGE", "development")
                        }
                    }
                }
            }
        }       
        publishers {
            groovyPostBuild("manager.addShortText(manager.build.getEnvironment(manager.listener)[\'POM_VERSION\'])")
        }
        promotions {
            promotion("Development") {
                icon("star-red")
                conditions {
                    manual('')
                }
                actions {
                    downstreamParameterized {
                        trigger("deploy-application","SUCCESS",false,["buildStepFailure": "FAILURE","failure":"FAILURE","unstable":"UNSTABLE"]) {
                            predefinedProp("ENVIRONMENT","test-server")
                            predefinedProp("APPLICATION_NAME", "\${PROMOTED_JOB_FULL_NAME}")
                            predefinedProp("BUILD_ID","\${PROMOTED_NUMBER}")
                        }
                    }
                }
            }
            promotion("QA") {
                icon("star-yellow")
                conditions {
                    manual('')
                    upstream("Development")
                }
                actions {
                    downstreamParameterized {
                        trigger("deploy-application","SUCCESS",false,["buildStepFailure": "FAILURE","failure":"FAILURE","unstable":"UNSTABLE"]) {
                            predefinedProp("ENVIRONMENT","qa-server")
                            predefinedProp("APPLICATION_NAME", "\${PROMOTED_JOB_FULL_NAME}")
                            predefinedProp("BUILD_ID","\${PROMOTED_NUMBER}")
                        }
                    }
                }
            }   
            promotion("Production") {
                icon("star-green")
                conditions {
                    manual('')
                    upstream("QA")
                }
                actions {
                    downstreamParameterized {
                        trigger("deploy-application","SUCCESS",false,["buildStepFailure": "FAILURE","failure":"FAILURE","unstable":"UNSTABLE"]) {
                            predefinedProp("ENVIRONMENT","prod-server")
                            predefinedProp("APPLICATION_NAME", "\${PROMOTED_JOB_FULL_NAME}")
                            predefinedProp("BUILD_ID","\${PROMOTED_NUMBER}")
                        }
                    }
                }
            }                           
        }       
    }   

1 个答案:

答案 0 :(得分:1)

createTag方法的语法略有变化。在这里查看最新的api文档。 https://jenkinsci.github.io/job-dsl-plugin/#method/javaposse.jobdsl.dsl.helpers.publisher.PublisherContext.git 如果您根本不想创建标签,则只删除该行。 新的语法为:

git {
    tag(String targetRepo, String name) {
        // If set, creates a new tag.
        create(boolean create = true)
        // Sets a message for the tag.
        message(String message)
        // If set, updates an existing tag.
        update(boolean update = true)
    }
}