如何修复“hudson.remoting.ProxyException:groovy.lang.MissingMethodException:没有方法签名:testFunc.call()”

2024-01-22

我正在尝试使用 Jenkins 中的共享库调用函数。共享库 groovy 文件存在于存储库的 /vars 文件夹中。

我尝试过共享库文件的其他名称。我尝试也使用 testFunc.call()、testFunc、testFunc() 来调用它

testFunc.groovy


import hudson.model.*
import hudson.EnvVars
import groovy.json.JsonSlurperClassic
import groovy.json.JsonBuilder
import groovy.json.JsonOutput
import groovy.json.*
import java.net.URL
def coveragepercentage
def testFunc(){

    def param = "${env:TestCoverage}"
    echo param
    def paramInt = param as int
    echo "Integer "+ paramInt
    def jsondata = readFile(file:'./target/site/munit/coverage/munit-coverage.json')
           def data = new JsonSlurperClassic().parseText(jsondata)
           coveragepercentage = data.coverage
           echo "${coveragepercentage}"

        if(coveragepercentage > paramInt){
           println("This value is smaller")
           sh "exit 1"
           currentBuild.result = 'FAILURE'
                }
}

使用上述共享库的 Jenkinsfile

@Library('shared-lib2') _
import hudson.model.*
import hudson.EnvVars
import groovy.json.JsonSlurperClassic
import groovy.json.JsonBuilder
import groovy.json.JsonOutput
import groovy.json.*
import java.net.URL
pipeline{
  agent any
    tools {
      maven 'Maven'
      jdk  'JAVA'
        }
    stages {
        stage('build') {
            steps {
                configFileProvider([configFile(fileId: 'config', variable: 'MAVEN_SETTINGS_XML')]) {
                sh "mvn -s $MAVEN_SETTINGS_XML clean package"
                }
            }
        }
        stage('test function'){
            steps{
                script{
                testFunc()
                }
            }
        }

        stage('MUnit Test Report') {
               steps{
                script {
                  publishHTML(target:[allowMissing: false,alwaysLinkToLastBuild: true,keepAll: true,reportDir: 'target/site/munit/coverage',reportFiles: 'summary.html',reportName: 'MUnit Test Report',reportTitles: 'MUnit Test Coverage Report'])
                }
                  }
            }   
    }

错误:hudson.remoting.ProxyException:groovy.lang.MissingMethodException:没有方法签名:testFunc.call() 适用于参数类型:() 值:[]


就我而言,我有

call() {

虽然应该是

def call() {

Shame.

本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)

如何修复“hudson.remoting.ProxyException:groovy.lang.MissingMethodException:没有方法签名:testFunc.call()” 的相关文章

随机推荐