简体   繁体   English

jenkinspipeline groovy.lang.MissingMethodException:没有方法签名

[英]jenkinspipeline groovy.lang.MissingMethodException: No signature of method

I have created a pipeline that takes an array of JSON objects and will call a shared library which will iterate over the JSON objects我创建了一个管道,它采用 JSON 对象数组,并将调用一个共享库,该库将遍历 JSON 对象

When trying to run the Jenkins job to test that I can forward the objects but I'm seeing the following error:尝试运行 Jenkins 作业以测试我是否可以转发对象但我看到以下错误:

hudson.remoting.ProxyException: groovy.lang.MissingMethodException: No signature of method: imageBuild.call() is applicable for argument types: (java.lang.String) values: [[{"dockerConfig":"home/pipelines/conf/journeys/dockerbuild.yaml","aquaConfig":"home/pipelines/conf/journeys/aquascan.yaml","gtag": "v1.0.1","preFixName": "journey1"},{"dockerConfig":"home/pipelines/conf/if.com/dockerbuild.yaml","aquaConfig":"home/pipelines/conf/if.com/aquascan.yaml","gtag": "v2.0.2","preFixName": "journey2"},{"dockerConfig":"home/pipelines/conf/colleague/dockerbuild.yaml","aquaConfig":"home/pipelines/conf/colleague/aquascan.yaml","gtag": "v3.0.3","preFixName": "journey2"}]]
Possible solutions: call(), call(java.util.Map), wait(), any(), wait(long), main([Ljava.lang.String;)
    at org.codehaus.groovy.runtime.ScriptBytecodeAdapter.unwrap(ScriptBytecodeAdapter.java:58)

Code:代码:

library identifier: 'jenkins-sharedlib-cooking@BB-3611', retriever: modernSCM([$class: 'GitSCMSource',
 remote: 'https://github.com/lbg-gcp-foundation/jenkins-sharedlib-cooking-lifecycle.git',
 credentialsId: 'jenkinsPAT'])

def configList = '[{"dockerConfig":"home/pipelines/conf/journeys/dockerbuild.yaml","aquaConfig":"home/pipelines/conf/journeys/aquascan.yaml","gtag": "v1.0.1","preFixName": "journey1"},{"dockerConfig":"home/pipelines/conf/if.com/dockerbuild.yaml","aquaConfig":"home/pipelines/conf/if.com/aquascan.yaml","gtag": "v2.0.2","preFixName": "journey2"},{"dockerConfig":"home/pipelines/conf/colleague/dockerbuild.yaml","aquaConfig":"home/pipelines/conf/colleague/aquascan.yaml","gtag": "v3.0.3","preFixName": "journey2"}]'

pipeline {
  environment {
    def config = 
    brand = 
    environmentName = 
    CLUSTER_NAME = 
    CLUSTER_PROJECT = 
    VERSION = '1.0.0'
  }

  options {
    ansiColor('xterm')
    timeout(time: 150, unit: 'MINUTES')
    disableConcurrentBuilds()
    buildDiscarder(logRotator(numToKeepStr: '100'))
  }

  agent {
    kubernetes {
      label "jrn-${UUID.randomUUID().toString()}"
      yamlFile "pipelines/conf/podTemplate.yaml"
    }
  }
stages {
    stage('Stage 6 - Docker Image ') {
      parallel {
        stage ('Docker Image - Journeys') {
          steps {
            echo "*********************** Docker Journeys ***********************************"
            container('docker') {
              echo "Building the docker image..."
imageBuild(configList)
            }
            archiveArtifacts artifacts: "*.html", allowEmptyArchive: true
          }
        }
      }enter code here
    }
  }

Looks like the groovy method or global variable imageBuild in the shared library Jenkins-shared lib-cooking@BB-3611 does not expecting any parameter but you are trying to pass a string, that's the reason you are getting MissingMethodException.看起来共享库 Jenkins-shared lib-cooking@BB-3611 中的 groovy 方法或全局变量imageBuild不需要任何参数,但您尝试传递字符串,这就是您收到 MissingMethodException 的原因。 with the details与细节

hudson.remoting.ProxyException: groovy.lang.MissingMethodException: No signature of method: imageBuild.call() is applicable for argument types: (java.lang.String) values

To fix the issue, you have to change the shared library method or global variable imageBuild from imageBuild() to imageBuild(String param) or imageBuild(def param)要解决此问题,您必须将共享库方法或全局变量 imageBuild 从imageBuild()更改为imageBuild(String param) or imageBuild(def param)

I will try to illustrate with an example similar to your example for your reference.我将尝试用与您的示例类似的示例进行说明,以供您参考。

Assuming you have a shared library in a git repository named - jenkins-sharedlib-cooking-lifecycle and you are following the folder structure suggested by Jenkins shared library documentation假设您在名为 - jenkins-sharedlib-cooking-lifecycle 的 git 存储库中有一个共享库,并且您遵循 Jenkins 共享库文档建议的文件夹结构

// vars/imageBuild.groovy
import groovy.json.JsonSlurper
def call(def imagebuildParameter) {
  def jsonSlurper = new JsonSlurper()
  def object = jsonSlurper.parseText(imagebuildParameter)
  // use loop on object to retrive the value like below  
  println object[0].name
}

//Jenkinsfile
node {
  stage('stageName') {
    def x = '[{"name": "foo"},{"name": "bar"}]'
    imageBuild(x)
  }
}

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 groovy.lang.MissingMethodException:方法的无签名:在詹金斯构建流程的groovy中 - groovy.lang.MissingMethodException: No signature of method: in groovy on jenkins buildflow Jenkins groovy.lang.MissingMethodException:没有方法签名:catchError() - Jenkins groovy.lang.MissingMethodException: No signature of method: catchError() groovy.lang.MissingMethodException:方法的无签名:java.util.ArrayList - groovy.lang.MissingMethodException: No signature of method: java.util.ArrayList hudson.remoting.ProxyException:groovy.lang.MissingMethodException:方法没有签名: - hudson.remoting.ProxyException: groovy.lang.MissingMethodException: No signature of method: 如何修复“hudson.remoting.ProxyException:groovy.lang.MissingMethodException:没有方法签名:testFunc.call()” - How to fix 'hudson.remoting.ProxyException: groovy.lang.MissingMethodException: No signature of method: testFunc.call() ' groovy.lang.MissingMethodException:没有方法签名:为什么 Jenkins 共享管道库会出现此错误? - groovy.lang.MissingMethodException: No signature of method: Why is this error coming for Jenkins Shared Pipeline library? hudson.remoting.ProxyException: groovy.lang.MissingMethodException: 没有方法签名: java.util.LinkedHashMap.call() 是适用的 - hudson.remoting.ProxyException: groovy.lang.MissingMethodException: No signature of method: java.util.LinkedHashMap.call() is applicable Jenkins Groovy构建作业错误groovy.lang.MissingMethodException - Jenkins groovy build job error groovy.lang.MissingMethodException Jenkins groovy MissingMethodException 没有方法签名 - Jenkins groovy MissingMethodException No signature of method 在 groovy 中,无法将字符串与正则表达式模式匹配。 groovy.lang.MissingMethodException 发生 - In groovy, not able to match a string with regex pattern. groovy.lang.MissingMethodException occurs
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM