Search code examples
jenkinsjenkins-job-dsl

Jenkins' Job DSL throws ConcurrentModificationException when I define a BooleanParameterDefinition


I'm trying to add a boolean parameter to an existing Jenkins job, but when I add it my seedjob stops working.

My job definition:

job('ci') {
    description 'Build and test the app.'
    scm {
        github 'sheehan/job-dsl-playground'
    }
    steps {
        gradle 'test'
    }
    publishers {
        archiveJunit 'build/test-results/**/*.xml'
    }
    configure { project ->
        project / 'properties' / 'hudson.model.ParametersDefinitionProperty' {
            'parameterDefinitions'  {
                'hudson.model.BooleanParameterDefinition' {
                    name('my-param')
                    description("my-param-description")
                    defaultValue(true)
                }
            }
        }
    }
}

You can reproduce the error by pasting the job definition code in this page: https://job-dsl.herokuapp.com/


Solution

  • The bug is still there, but I managed to work around it by removing the BooleanParameterDefinition's description. So my final code looks like this:

    job('ci') {
        description 'Build and test the app.'
        scm {
            github 'sheehan/job-dsl-playground'
        }
        steps {
            gradle 'test'
        }
        publishers {
            archiveJunit 'build/test-results/**/*.xml'
        }
        configure { project ->
            project / 'properties' / 'hudson.model.ParametersDefinitionProperty' {
                'parameterDefinitions'  {
                    'hudson.model.BooleanParameterDefinition' {
                        name('my-param')
                        defaultValue(true)
                    }
                }
            }
        }
    }