manish soni
manish soni

Reputation: 575

how to fix hudson.remoting.ProxyException: groovy.lang.MissingMethodException: No signature of method

i have two pipelines and when i call another shared library i got following error-

hudson.remoting.ProxyException: groovy.lang.MissingMethodException: No signature of method: genric.call() is applicable for argument types: () values: [] Possible solutions: wait(), any(), wait(long), main([Ljava.lang.String;), any(groovy.lang.Closure), each(groovy.lang.Closure)

Followings are my both files.

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()
            }
        }
   }
}

How to solve it?

ignore environment field

Upvotes: 1

Views: 13610

Answers (2)

Dillip Kumar Behera
Dillip Kumar Behera

Reputation: 289

You have to rewrite something like this:

vars/genric.groovy file

call() {
    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()
            }
        }
   }
}

Upvotes: 0

Dillip Kumar Behera
Dillip Kumar Behera

Reputation: 289

The syntax used in genric.groovy is wrong, this file should be placed inside the vars folder of shared library repo and follows the syntax described in the "Defining custom steps" section of below link:

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

Upvotes: 1

Related Questions