简体   繁体   English

带有 GDSL 的 IntelliJ 中的 Jenkins 管道。 警告:“节点”不能应用于“(groovy.lang.closure<object> )'<div id="text_translate"><p> 我将 Jenkins 与 Pipelines 一起使用,并使用Jenkinsfile定义了一个<em>脚本化的管道</em>。 它看起来像这样:</p><pre> node { /* some stages */ }</pre><p> 我已将 Jenkins 附带的 GDSL 文件导入 IntelliJ。 现在我得到了语法突出显示,但整个文件在单个警告块中突出显示,IntelliJ 显示以下消息:</p><pre> 'node' cannot be applied to '(groovy.lang.closure&lt;Object&gt;)'</pre><p> 我认为可能是语法定义不支持节点 object 作为 root,但是如果我尝试以 root 身份编写pipeline ,则会出现相同的警告。</p></div></object>

[英]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.

相关问题 Groovy Date()对象无法在Jenkins管道中进行创建 - Groovy Date() object cannot be creted in Jenkins pipeline 詹金斯管道 - groovy.lang.MissingPropertyException - Jenkins pipeline - groovy.lang.MissingPropertyException Jenkins管道groovy.lang.MissingPropertyException - Jenkins pipeline groovy.lang.MissingPropertyException Jenkins管道插件MissingPropertyException没有这样的属性:类的节点:groovy.lang.Binding - Jenkins Pipeline plugin MissingPropertyException No such property: node for class: groovy.lang.Binding Jenkins 管道中的 Artifactory:org.codehaus.groovy.runtime.GStringImpl 不能转换为 java.lang.String - Artifactory in Jenkins pipeline: org.codehaus.groovy.runtime.GStringImpl cannot be cast to java.lang.String Jenkins 管道 groovy java.lang.IllegalStateException:意外中断语句 - Jenkins pipeline groovy java.lang.IllegalStateException: unexpected break statement Jenkins 声明性管道 groovy.lang.MissingPropertyException:没有此类属性:class 的阶段:Z5F202E7AB75AE600CZ. - Jenkins declarative pipeline groovy.lang.MissingPropertyException: No such property: stage for class: groovy.lang 詹金斯管道技术 - Jenkins pipeline groovy jenkins groovy 管道排序 - jenkins groovy pipeline sorting Jenkins Groovy 管道获取 (Windows) 每个节点的用户文件夹 - Jenkins Groovy Pipeline Get (Windows)User Folder Per Node
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM