我们计划将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!')
}
}
}
}
如何解决此问题?
答案 0 :(得分:2)
在Job DSL 1.43中已弃用对GitHub Pull Request Builder插件的内置支持。新语法由GitHub Pull Request Builder插件的1.29.7或更高版本通过扩展提供。因此,您需要将GitHub Pull Request Builder插件更新为1.29.7或更高版本。
答案 1 :(得分:0)
唯一的方法是回退到手动配置块:
job.configure {
def trigger = it / triggers
trigger << 'org.jenkinsci.plugins.ghprb.GhprbTrigger' {
adminlist JobConstants.GITHUB_PR_ADMIN
whitelist ''
orgslist JobConstants.ORG_WHITE_LIST
cron '* * * * *'
spec '* * * * *'
triggerPhrase phrase
onlyTriggerPhrase false
useGitHubHooks false
permitAll true
autoCloseFailedPullRequests false
commentFilePath ''
allowMembersOfWhitelistedOrgsAsAdmin true
extensions {
'org.jenkinsci.plugins.ghprb.extensions.status.GhprbSimpleStatus' {
commitStatusContext 'Pull Request Pipeline'
triggeredStatus 'Build Triggered!'
startedStatus 'Build Started!'
statusUrl ''
completedStatus {
'org.jenkinsci.plugins.ghprb.extensions.comments.GhprbBuildResultMessage' {
message 'Went green! Go ahead and merge ${ghprbSourceBranch} into ${ghprbTargetBranch}.'
result 'SUCCESS'
}
'org.jenkinsci.plugins.ghprb.extensions.comments.GhprbBuildResultMessage' {
message 'Something went wrong. Click details!'
result 'FAILURE'
}
'org.jenkinsci.plugins.ghprb.extensions.comments.GhprbBuildResultMessage' {
message 'Something went really wrong. Click details!'
result 'ERROR'
}
}
}
}
}
}