在Jenkins dsl中更改github提交状态

时间:2018-03-19 06:50:02

标签: git jenkins dsl jenkins-job-dsl

我正在尝试更改Jenkins中的构建的提交状态(我将sha作为参数构建)。

我正在使用 DSL插件而不是管道插件。 我尝试使用以下解决方案How to set github commit status with Jenkinsfile NOT using a pull request builder,但我无法使其工作(因为我没有DSL中的step()阶段)

.navbarSection {
display: inline;
}

.topnav {
float:left
}

.right-nav {
float:right;
background-color: #aa2222;
overflow: hidden;
}

失败并出现以下错误:

def setBuildStatus(String message, String state, String context, String sha) {
    step([
            $class: "GitHubCommitStatusSetter",
            reposSource: [$class: "ManuallyEnteredRepositorySource", url: "https://github.com/<yourRepoURL>"],
            contextSource: [$class: "ManuallyEnteredCommitContextSource", context: context],
            errorHandlers: [[$class: "ChangingBuildStatusErrorHandler", result: "UNSTABLE"]],
            commitShaSource: [$class: "ManuallyEnteredShaSource", sha: sha ],
            statusBackrefSource: [$class: "ManuallyEnteredBackrefSource", backref: "${BUILD_URL}flowGraphTable/"],
            statusResultSource: [$class: "ConditionalStatusResultSource", results: [[$class: "AnyBuildResult", message: message, state: state]] ]
    ]);
}

job('deploy') {

    scm {
        git {
            remote {
                github('owner/repo', 'ssh')
            }
        }
    }
    parameters {
        stringParam('git_commit', null)
    }



    setBuildStatus("In Progress", "PENDING", "Deploy", "\${git_commit}")

}

有没有办法将GitHubCommitStatusSetter用作DSL工作的一部分?我失踪的任何其他方式?

0 个答案:

没有答案