Jenkinsfile 中 运行 kubectl 和 helm 命令后的空指针异常

Nullpointer exception after running kubectl and helm command in Jenkinsfile

我试图在 Jenkinsfile 的部署步骤中使用 运行 kuberneteshelm 命令,但我遇到了 Nullpointer 异常。下面是我的代码:

stage ('Create and Deploy to k8s Dev Environment') {
            //agent {label 'docker-maven-slave'}
            options {
                skipDefaultCheckout()
            }
            steps {
                withCredentials([string(credentialsId: K8S_DEV_SECRET_ID)]) {
                    command """

                    kubectl apply --server=https://10.0.0.0:443 --insecure-skip-tls-verify=false --namespace: "dev-ns" -f -

                    helm template -f "portal-chart/deploy/values-dev.yaml" portal-chart
                    """
                }
}

以下是日志:

[Pipeline] End of Pipeline
hudson.remoting.ProxyException: java.lang.NullPointerException
Caused: hudson.remoting.ProxyException: com.xxx.jenkins.pipeline.library.utils.dispatch.ShellCommandException: Exception calling shell command, 'kubectl apply ... ': null
    at command.call(command.groovy:51)

我能够解决这个问题。下面是代码:

stage ('Create and Deploy to k8s Dev Environment') {
            //agent {label 'docker-maven-slave'}
            options {
                skipDefaultCheckout()
            }
            steps {
                    command """

                    kubectl apply --server=https://10.0.0.0:443 --insecure-skip-tls-verify=false --namespace: "dev-ns" -f -

                    helm template -f "portal-chart/deploy/values-dev.yaml" portal-chart
                    """
                
}