Search code examples
jenkinsjenkins-job-dsl

Jenkins JobDSL Promoted-Builds


I'm running

Jenkins 2.235.1 
promoted-builds 3.5
JobDSL 1.77

When I do the small example as the documentation says.

properties {
    promotions {
        promotion {
            name('build')
            icon('star-silver')
            condition {
                selfPromotion('false')
            }
        }
    }
}

I get the following error:

Caused by: javaposse.jobdsl.dsl.DslScriptException: (script, line 86) No signature of method: javaposse.jobdsl.dsl.helpers.properties.PropertiesContext.promotions() is applicable for argument types: (webshop_v8.script$_run_closure1$_closure7$_closure20) values: [webshop_v8.script$_run_closure1$_closure7$_closure20@265f0971]

According to the documentation, I have added it correctly, but my jobDslTest doesn't allow it. Someone that can give me a hint? I'm sort of lost atm.


Solution

  • The problem was in my case:

    We are using the Job DSL Plugin(1) that provides tests for us, to execute them locally before pushing the commit.

    This plugin was still using an old version of Jenkins, by adding a newer version to my build.gradle my problem was solved.

    dependencies  {
        .
        .
        .
        jobDslTestRuntime "org.jenkins-ci.main:jenkins-war:2.235.1"
    }
    
    1. https://github.com/AOEpeople/gradle-jenkins-job-dsl-plugin