Jenkins Job / Pipeline DSL,包括具有重复功能的常规文件

问题描述

文件job.groovy中,我有

def paramOne = 'test'
def paramTwo = ['latest','dev']
    
    shell(readFileFromWorkspace('function.groovy'))

在function.groovy中,我有

def dockerJobFunction = {
    paramTwo.each { paramSet ->
        pipelineJob("${paramOne}-${paramTwo}") {
            properties {
                githubProjectUrl('https://github.com/xxxx/xxxx_xxxx/')
            }

            parameters {
                choiceParam('BUILD_TYPE',['dev','prod'],'Select an image build type')

                wReadonlyStringParameterDeFinition {
                    name('paramOne')
                    defaultValue(paramOne)
                    description('Param One')
                }

                wReadonlyStringParameterDeFinition {
                    name('paramTwo')
                    defaultValue(paramTwo)
                    description('Param Two')
                }
            }

            deFinition {
                cps {
                    script(readFileFromWorkspace('pipelines/stuff.groovy'))
                    sandBox()
                }
            }

            logrotator {
                numToKeep(100)
            }
        }
    }
}

尝试在gradle测试中包含功能信息时出现以下错误

com.xxxxdsl.JobScriptsspec > test script android.groovy Failed
    org.spockframework.runtime.UnallowedExceptionThrownError at JobScriptsspec.groovy:45
        Caused by: javaposse.jobdsl.dsl.DslScriptException at JobScriptsspec.groovy:41

97 tests completed,1 Failed

如何从功能文件中包含groovy dsl工作?

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)