【问题标题】:how to fix hudson.remoting.ProxyException: groovy.lang.MissingMethodException: No signature of method如何修复 hudson.remoting.ProxyException:groovy.lang.MissingMethodException:没有方法签名
【发布时间】:2019-08-23 10:33:35
【问题描述】:

我有两个管道,当我调用另一个共享库时出现以下错误-

hudson.remoting.ProxyException:groovy.lang.MissingMethodException:没有方法签名:genric.call() 适用于参数类型:() 值:[] 可能的解决方案:wait()、any()、wait(long)、main([Ljava.lang.String;)、any(groovy.lang.Closure)、each(groovy.lang.Closure)

以下是我的两个文件。

genric.groovy file
#!/usr/bin/env groovy
//import hudson.model.*
pipeline{
    agent any
    stages{
        stage('build-deploy'){
            steps{
                sh''' 
                cd /home/manish/Desktop/test/
                mkdir testing
                '''
             }
         }
     }
 }

 Jenkinsfile
 library identifier: 'genric.groovy@master', retriever:          modernSCM([$class: 'GitSCMSource', credentialsId: '', remote: 'https://github.com/mani1soni/jenkins-practice.git', traits: [[$class: 'jenkins.plugins.git.traits.BranchDiscoveryTrait']]])
 pipeline{
    agent any
    environment{
        REPO_PATH='/home/manish/Desktop'
        APP_NAME='test'
    }
    stages{
       stage('calling function'){
           steps{
               genric()
            }
        }
   }
}

如何解决?

忽略环境字段

【问题讨论】:

  • 在 Dilip 共享的链接中,它解释说您可以使用带有单个文件的 vars 文件夹来定义步骤或定义整个管道定义(“定义声明性管道”部分。您不能将这两者混合使用。

标签: groovy jenkins-pipeline shared-libraries


【解决方案1】:

genric.groovy 中使用的语法错误,该文件应放在共享库 repo 的 vars 文件夹中,并遵循以下链接的“定义自定义步骤”部分中描述的语法:

https://jenkins.io/doc/book/pipeline/shared-libraries/

【讨论】:

  • 如果它已经在 vars 文件夹中,那么您应该遵循允许在 groovy 脚本上写入任何内容的语法,例如: def call(String name="World") { echo("Hello, ${name }.") }
【解决方案2】:

你必须像这样重写:

vars/genric.groovy 文件

call() {
    sh''' 
        cd /home/manish/Desktop/test/
        mkdir testing
    '''
}

詹金斯文件

 library identifier: 'genric.groovy@master', retriever:          modernSCM([$class: 'GitSCMSource', credentialsId: '', remote: 'https://github.com/mani1soni/jenkins-practice.git', traits: [[$class: 'jenkins.plugins.git.traits.BranchDiscoveryTrait']]])
 pipeline{
    agent any
    environment{
        REPO_PATH='/home/manish/Desktop'
        APP_NAME='test'
    }
    stages{
       stage('calling function'){
           steps{
               genric()
            }
        }
   }
}

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2021-09-13
    • 2020-08-31
    • 1970-01-01
    • 2022-09-24
    • 2021-04-03
    • 1970-01-01
    相关资源
    最近更新 更多