[英]Jenkins pipeline in IntelliJ with GDSL. Warning: 'node' cannot be applied to '(groovy.lang.closure<Object>)'
I am using Jenkins with Pipelines and have defined a scripted pipeline using a Jenkinsfile
.我将 Jenkins 与 Pipelines 一起使用,并使用Jenkinsfile
定义了一个脚本化的管道。 It looks something like this:它看起来像这样:
node {
/* some stages */
}
I have imported the GDSL File that comes with Jenkins into IntelliJ.我已将 Jenkins 附带的 GDSL 文件导入 IntelliJ。 Now I got syntax highlighting but the whole file is being highlighted in a single warning block for which IntelliJ shows the following message:现在我得到了语法突出显示,但整个文件在单个警告块中突出显示,IntelliJ 显示以下消息:
'node' cannot be applied to '(groovy.lang.closure<Object>)'
I thought it might be that the node object is not supported as root by the syntax definition, but if i try to write pipeline
as root then the same warning appears.我认为可能是语法定义不支持节点 object 作为 root,但是如果我尝试以 root 身份编写pipeline
,则会出现相同的警告。
I found a solution. 我找到了解决方案。 A small change is required in the pipeline.gdsl
file (eg the GDSL file which was downloaded from Jenkins and placed into IntelliJ by us). 在pipeline.gdsl
文件中需要进行一些小的更改(例如,从Jenkins下载并由我们放入IntelliJ的GDSL文件)。
Find the following line in the gdsl file: 在gdsl文件中找到以下行:
method(name: 'node', type: 'Object',
params: [label:java.lang.String, body:'Closure'],
doc: 'Allocate node')
And add this line in addition to the previous one: 除了前一行之外还添加此行:
method(name: 'node', type: 'Object',
params: [body:'Closure'],
doc: 'Allocate node')
This will create an overload definition in the Syntax tree that tells IntelliJ that the node method has two version one which accepts both a String
and a Closure
, and another which accepts only a Closure
. 这将在语法树中创建一个重载定义,告诉IntelliJ节点方法有两个版本1接受String
和一个Closure
,另一个只接受Closure
。
To solve the same issue, but with pipeline
:要解决相同的问题,但要使用pipeline
:
'pipeline' cannot be applied to '(groovy.lang.Closure)' “管道”不能应用于“(groovy.lang.Closure)”
Add:添加:
method(name: 'pipeline', type: 'Object', params: [body:'Closure'], doc: 'Pipeline root element')
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.