小编典典

job-dsl-core jar版本更新为1.44,githubPullRequest关闭不起作用

jenkins

我们计划将job-dsl-core版本从1.42更新到1.44,但在最新版本中,不推荐使用pullRequest
{}闭包,并替换为githubPullRequest {}闭包,如迁移文档中所述,请参见 https://github.com/jenkinsci /
job-dsl-plugin / wiki / Migration#github-pull-request-
builder。当我尝试使用上述建议更新代码时,出现以下错误:

No signature of method: javaposse.jobdsl.dsl.helpers.triggers.TriggerContext.githubpullRequest() is applicable for argument types: (com.xxx.dva.pipeline.generator.utils.JobUtil$_addGithubPullRequestBuilderConfig_closure2_closure22) values: [com.xxx.dva.pipeline.generator.utils.JobUtil$_addGithubPullRequestBuilderConfig_closure2_closure22@7e3918d6]
at sun.reflect.GeneratedConstructorAccessor17.newInstance(Unknown Source)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
at java.lang.reflect.Constructor.newInstance(Constructor.java:422)
at org.codehaus.groovy.reflection.CachedConstructor.invoke(CachedConstructor.java:77)
at org.codehaus.groovy.runtime.callsite.ConstructorSite$ConstructorSiteNoUnwrapNoCoerce.callConstructor(ConstructorSite.java:102)
at org.codehaus.groovy.runtime.callsite.AbstractCallSite.callConstructor(AbstractCallSite.java:198)
at javaposse.jobdsl.dsl.AbstractExtensibleContext.methodMissing(AbstractExtensibleContext.groovy:20)
at sun.reflect.GeneratedMethodAccessor10.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:497)
at org.codehaus.groovy.reflection.CachedMethod.invoke(CachedMethod.java:90)
at groovy.lang.MetaClassImpl.invokeMissingMethod(MetaClassImpl.java:830)
at groovy.lang.MetaClassImpl.invokePropertyOrMissing(MetaClassImpl.java:1128)
at groovy.lang.MetaClassImpl.invokeMethod(MetaClassImpl.java:1081)
at groovy.lang.MetaClassImpl.invokeMethod(MetaClassImpl.java:903)
at groovy.lang.MetaClassImpl.invokeMethod(MetaClassImpl.java:723)

代码更改为:

版本1.42

job.triggers {
        pullRequest {
            admin(JobConstants.GITHUB_PR_ADMIN)
            orgWhitelist(JobConstants.ORG_WHITE_LIST)
            cron('* * * * *')
            permitAll()
            allowMembersOfWhitelistedOrgsAsAdmin()
            triggerPhrase(phrase)
            onlyTriggerPhrase(useTriggerPhrase)
            extensions {
                commitStatus {
                    context('Pull Request Pipeline')
                    triggeredStatus('Build Triggered!')
                    startedStatus('Build Started!')
                    completedStatus('SUCCESS', 'Went green! Go ahead and merge ${ghprbSourceBranch} into ${ghprbTargetBranch}.')
                    completedStatus('FAILURE', 'Something went wrong. Click details!')
                    completedStatus('ERROR', 'Something went really wrong. Click details!')
                }
            }
        }
    }

版本1.44

 job.triggers {
        githubPullRequest {
            admin(JobConstants.GITHUB_PR_ADMIN)
            orgWhitelist(JobConstants.ORG_WHITE_LIST)
            cron('* * * * *')
            permitAll()
            allowMembersOfWhitelistedOrgsAsAdmin()
            triggerPhrase(phrase)
            onlyTriggerPhrase(useTriggerPhrase)
            extensions {
                commitStatus {
                    context('Pull Request Pipeline')
                    triggeredStatus('Build Triggered!')
                    startedStatus('Build Started!')
                    completedStatus('SUCCESS', 'Went green! Go ahead and merge ${ghprbSourceBranch} into ${ghprbTargetBranch}.')
                    completedStatus('FAILURE', 'Something went wrong. Click details!')
                    completedStatus('ERROR', 'Something went really wrong. Click details!')
                }
            }
        }
    }

如何解决此问题?


阅读 313

收藏
2020-07-25

共1个答案

小编典典

Job DSL 1.43中已弃用了对GitHub Pull Request Builder插件的内置支持。GitHub Pull Request
Builder插件的版本1.29.7或更高版本通过扩展提供了新语法。因此,您需要将GitHub Pull Request
Builder插件更新为1.29.7或更高版本。

2020-07-25