简体   繁体   English

jenkins DSL与配置模块中的脚本编辑器插件不起作用

[英]jenkins dsl with scriptler plugin in configure block not working

I am able to create a job using the jenkins playground here http://job-dsl.herokuapp.com/ to where the xml is exactly like the config.xml of a manually created job, but when i run the seed for the job the job in the script below is created, but my configure block is completely ignored. 我可以使用詹金斯游乐场( http://job-dsl.herokuapp.com/)来创建作业,该xml与手动创建的作业的config.xml完全一样,但是当我为该作业运行种子时下面脚本中的作业已创建,但是我的configure块被完全忽略了。 The plugin needed is installed, i can configure this manually, but i cannot configure it using the DSL. 所需的插件已安装,我可以手动配置它,但是我无法使用DSL配置它。

here is my dsl script. 这是我的dsl脚本。

def disabledAll = false;

def projects = [
    [name: 'test-job', description: 'Test Job', branch: 'develop', disabled: disabledAll]]

projects.each { project ->
    job(project.name) {
        disabled(project.disabled)


    description(project.description)
    keepDependencies(false)

    properties {

    }

authorization {
    permission('hudson.model.Item.Read:test')
    permission('hudson.model.Item.Workspace:test')
    permission('hudson.model.Item.Build:test')
}

parameters {
    stringParam('TAG', null, null)
}

steps() {
    shell('export BUILD_VERSION=\${BUILD_VERSION} \nexport TAG=\${TAG} \n #run grunt build \ncd /var/lib/jenkins/buildcode/ \n#grunt distribute --verbose --build=\${BUILD_VERSION} --branch=\${TAG} \ngrunt distribute --build=\${BUILD_VERSION} --branch=\${TAG}')
}


configure { 
    it / 'properties' / 'hudson.model.ParametersDefinitionProperty' / 'parametersDefinitions' << 'com.seitenbau.jenkins.plugins.dynamicparameter.scriptler.ScriptlerStringParameterDefinition' {
        name('BUILD_VERSION')
        description('Overall Build version')
        __uuid('1515be93-8945-4247-b0dc-798452187a2b')
        __remote(false)
        __scriptlerScriptId('lat_build_values.groovy')
    }

}


}

} }

xml output: xml输出:

<project>
    <actions></actions>
    <description>Test Job</description>
    <keepDependencies>false</keepDependencies>
    <properties>
        <hudson.security.AuthorizationMatrixProperty>
            <blocksInheritance>false</blocksInheritance>
            <permission>hudson.model.Item.Read:test</permission>
            <permission>hudson.model.Item.Workspace:test</permission>
            <permission>hudson.model.Item.Build:test</permission>
        </hudson.security.AuthorizationMatrixProperty>
        <hudson.model.ParametersDefinitionProperty>
            <parameterDefinitions>
                <hudson.model.StringParameterDefinition>
                    <name>TAG</name>
                    <defaultValue></defaultValue>
                </hudson.model.StringParameterDefinition>
            </parameterDefinitions>
            <parametersDefinitions>
                <com.seitenbau.jenkins.plugins.dynamicparameter.scriptler.ScriptlerStringParameterDefinition>
                    <name>BUILD_VERSION</name>
                    <description>Overall Build version seen in the Business Manager</description>
                    <__uuid>1515be93-8945-4247-b0dc-798452187a2b</__uuid>
                    <__remote>false</__remote>
                    <__scriptlerScriptId>lat_build_values.groovy</__scriptlerScriptId>
                </com.seitenbau.jenkins.plugins.dynamicparameter.scriptler.ScriptlerStringParameterDefinition>
            </parametersDefinitions>
        </hudson.model.ParametersDefinitionProperty>
    </properties>
    <scm class='hudson.scm.NullSCM'></scm>
    <canRoam>true</canRoam>
    <disabled>false</disabled>
    <blockBuildWhenDownstreamBuilding>false</blockBuildWhenDownstreamBuilding>
    <blockBuildWhenUpstreamBuilding>false</blockBuildWhenUpstreamBuilding>
    <triggers class='vector'></triggers>
    <concurrentBuild>false</concurrentBuild>
    <builders>
        <hudson.tasks.Shell>
            <command>export BUILD_VERSION=${BUILD_VERSION} 
export TAG=${TAG} 
 #run grunt build 
cd /var/lib/jenkins/buildcode/ 
#grunt distribute --verbose --build=${BUILD_VERSION} --branch=${TAG} 
grunt distribute --build=${BUILD_VERSION} --branch=${TAG}</command>
        </hudson.tasks.Shell>
    </builders>
    <publishers></publishers>
    <buildWrappers></buildWrappers>
</project>

Any idea what i need to do for this to actually create the config in the job? 任何想法我需要为此真正在工作中创建配置吗?

There is a typo in an element name. 元素名称中有一个错字。 It's parameterDefinitions not parametersDefinitions . 它是parameterDefinitions而不是parametersDefinitions

This should work: 这应该工作:

job('example') {
  configure { 
    it / 'properties' / 'hudson.model.ParametersDefinitionProperty' / 'parameterDefinitions' << 'com.seitenbau.jenkins.plugins.dynamicparameter.scriptler.ScriptlerStringParameterDefinition' {
      name('BUILD_VERSION')
      description('Overall Build version')
      __uuid('1515be93-8945-4247-b0dc-798452187a2b')
      __remote(false)
      __scriptlerScriptId('lat_build_values.groovy')
    }
  }
}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM