I'm trying to change the commit status for a build in Jenkins (I get the sha as parameter build).
I'm using the DSL plugin and not the pipeline plugin. I tried using the following solution How to set github commit status with Jenkinsfile NOT using a pull request builder but I can't make it work (as I don't have the step() phase in the DSL)
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}")
}
It fails with the following error:
ERROR: (deploy_production.groovy, line 9) No signature of method: deploy_production.step() is applicable for argument types: (java.util.LinkedHashMap) values: [[$class:GitHubCommitStatusSetter, reposSource:[$class:ManuallyEnteredRepositorySource, ...], ...]]
Possible solutions: grep(), grep(java.lang.Object), sleep(long), dump(), setJm(javaposse.jobdsl.dsl.JobManagement), getJm()
Is there a way to use the GitHubCommitStatusSetter as part of the DSL job? any other way I'm missing?