Search code examples
kubernetesjenkins-pipelinekubernetes-helmjenkins-groovy

How do I resolve "Error: "helm template" requires at least 1 argument"?


I am trying to run helm command in the Jenkinsfile pipeline and I am getting an error that it is expecting at least 1 argument. Below is the code:

stage ('Create and Deploy to k8s Dev Environment') {
            //agent {label 'docker-maven-slave'}
            options {
                skipDefaultCheckout()
            }
            steps {                    
                    command """
                        echo "hiiiiiiii"
                        helm template -f portal-chart/values-dev.yaml --set image.tag=${IMAGE} | \
                        kubectl apply --server=https://dddd.gggg.com:443 --token='${DEV_NS_TOKEN}' --insecure-skip-tls-verify=true -f -
                    """

}

Below are the logs:

+ echo hiiiiiiii
hiiiiiiii
+ helm template -f portal-chart/values-dev.yaml --set image.tag=bde8ac5
+ kubectl apply --server=https://dddd.gggg.com:443 --token=eyjsfkjdhfkjdhfkjdhfkjhfdjhfjdfjZCI6IlI5Zi1YOFpnd2NzcUpUR1czTG45aUhwR2dHMkYx --insecure-skip-tls-verify=true -f -
Error: "helm template" requires at least 1 argument

Usage:  helm template [NAME] [CHART] [flags]
error: no objects passed to apply
[Pipeline] }
[Pipeline] // stage
[Pipeline] }
[Pipeline] // withEnv
[Pipeline] }
[Pipeline] // withEnv
[Pipeline] }
[Pipeline] // node
[Pipeline] End of Pipeline

Please verify my helm command and let me know if I am missing something over here.


Solution

  • You must specify the Chartparameter.

    helm template --help
       Usage:
         helm template [NAME] [CHART] [flags]
    

    In your case it should be

     helm template -f portal-chart/values-dev.yaml --set image.tag=${IMAGE} portal-chart
    

    -f only specifies the values file! You also must specify for which chart it should be applied on.