Jenkins DSL script - Test Failure - Found multiple extensions which provide method lastCompleted

最后都变了- 提交于 2019-12-10 11:56:15

问题


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.

I am using copy artifact to copy the results of downstream jobs to the multijob's target dir. Using selector - 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.

Here is my script:

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)
            }
   }
}

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!


回答1:


I had come across the same issue few months back. There are two possible solutions to this issue.

1 - Keep only one plugin that will avoid the conflict. (Not recommended as it might break other jobs)

2- Use configure block to modify the xml file which will avoid this conflict & you can keep multiple plugins that support the same extensions. (Recommended solution)

Thanks,




回答2:


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.

Better do use Pipelines.



来源:https://stackoverflow.com/questions/51564810/jenkins-dsl-script-test-failure-found-multiple-extensions-which-provide-meth

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!