本文介绍了Jenkins DSL脚本-测试失败-找到多个扩展,这些扩展提供了lastCompleted方法的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

尝试使用DSL脚本在Jenkins中创建多作业.

Trying to create multijobs in Jenkins with DSL scripting.

一个阶段中有多个作业,我想为下游作业中的多作业创建一个合并报告.

There are multiple jobs in a phase and I want to create a consolidated report for the multijob from downstream jobs.

我正在使用复制工件将下游作业的结果复制到多作业的目标目录中.使用选择器-lastCompleted()

I am using copy artifact to copy the results of downstream jobs to the multijob's target dir. Using selector - lastCompleted()

但是我收到一个错误消息,提示提供方法和测试的多个扩展失败.显然,存在于copyArtifact和multijob插件中的lastCompleted()在这种情况下,我需要同时使用两者.

However I am getting this an error saying multiple extensions providing the method and tests are failing. lastCompleted() is apparently present in copyArtifact and multijob plugins where in this case I require both.

这是我的剧本:

multiJob('dailyMultiJob') {
concurrentBuild(true)
logRotator(-1, 10, -1, 10)
triggers {
    cron('H H(0-4) * * 0-6')
}
steps {
        phase('Smoke Tests'){
            phaseJob('JobA')
            phaseJob('JobB')
            phaseJob('JobC')                
        }
        copyArtifacts{
            selector{
                lastCompleted()    
            }
            projectName('JobA')
            filter('target/allure-results/*.*')
            target('/path/to/this/multijob/workspace')
            flatten(false)
        }           
        copyArtifacts{
            selector{
                lastCompleted()    
            }
            projectName('JobB')
            filter('target/allure-results/*.*')
            target('/path/to/this/multijob/workspace')
            flatten(false)
        }           
        copyArtifacts{
            selector{
                lastCompleted()    
            }
            projectName('JobC')
            filter('target/allure-results/*.*')
            target('/path/to/this/multijob/workspace')
            flatten(false)
        }           

}
publishers {
            allure {
                results {
                    resultsConfig {
                        path('target/allure-results')
                    }
                }
            }
            archiveArtifacts {
                pattern('target/reports/**/*.*')
                pattern('target/allure-results/**/*.*')
                allowEmpty(true)
            }
   }
}

在运行gradle测试后得到以下错误

Getting this below error after running gradle tests

Caused by: javaposse.jobdsl.dsl.DslException: Found multiple extensions which provide method lastCompleted with arguments []: [[hudson.plugins.copyartifact.LastCompletedBuildSelector, com.tikal.jenkins.plugins.multijob.MultiJobBuildSelector]]

我不确定是否有办法表明使用特定工件的方法.

I am not sure if there is a way to indicate use specific artifact's method.

在这个问题上停留了很长时间.任何帮助都将受到高度赞赏.先感谢您!

Been stuck on this for quite some time. Any helps are highly appreciated. Thank you in advance!

推荐答案

最新更新:我要做的是改为切换到脚本化管道作业.实际上,并非要在所有要使用的方法上使用配置块,并且它们受设计的限制.我相信出于安全原因,某些插件也不允许使用它.

Late update:What I had to do is to switch to scripted pipeline jobs instead.Configure blocks are not really allowed on all the methods you want to use and they are limited by design. I believe some plugins also don't allow it for security reasons.

最好使用管道.

这篇关于Jenkins DSL脚本-测试失败-找到多个扩展,这些扩展提供了lastCompleted方法的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-24 19:21