helm test via Jenkins pipeline

10/31/2019

I'm running a basic groovy Jenkins pipeline as code for establishing a successful connection to a kubernetes cluster. Below is the code snippet which is trying to connect to a k8s cluster and listing all the releases.

   stage('Helm list'){
        steps{
                withCredentials([file(credentialsId: "kubeconfig-gke", variable:"kubeconfig")])
                {
                    helm list -a
                }
            }
    }

I get the following error on Jenkins console output : groovy.lang.MissingPropertyException: No such property: list for class: groovy.lang.Binding Possible solutions: class at groovy.lang.Binding.getVariable(Binding.java:63) at org.jenkinsci.plugins.scriptsecurity.sandbox.groovy.SandboxInterceptor.onGetProperty(SandboxInterceptor.java:270) at org.kohsuke.groovy.sandbox.impl.Checker$6.call(Checker.java:289) at org.kohsuke.groovy.sandbox.impl.Checker.checkedGetProperty(Checker.java:293) at org.kohsuke.groovy.sandbox.impl.Checker.checkedGetProperty(Checker.java:269)

-- Avi
jenkins-groovy
jenkins-pipeline
kubernetes-helm

1 Answer

11/1/2019

Run it inside a shell command

        steps{
                withCredentials([file(credentialsId: "kubeconfig-gke", variable:"kubeconfig")])
                {
                 sh """
                    helm list -a
                 """
                }
            }
        }
-- Anish
Source: StackOverflow