How to use helm commands in jenkins pipeline script

admin

Administrator
Staff member
I have been trying to deploy the image built on jenkins by docker to helm charts, i have referred couple of documents on website <a href="https://dev.to/sword-health/seamless-ci-cd-with-jenkins-helm-and-kubernetes-5e00" rel="nofollow noreferrer">https://dev.to/sword-health/seamless-ci-cd-with-jenkins-helm-and-kubernetes-5e00</a>
and <a href="https://cloudcompilerr.wordpress.co...kubernetes-run-jenkins-on-kubernetes-cluster/" rel="nofollow noreferrer">https://cloudcompilerr.wordpress.co...kubernetes-run-jenkins-on-kubernetes-cluster/</a> and managed till the point where docker image gets pushed into dockerhub but i get stuck at helm
i'm not getting what the error exactly is.
<strong>JENKINS ERROR</strong>
Code:
+ helm list
/var/lib/jenkins/workspace/[email protected]/durable-68e91f76/script.sh: 1: /var/lib/jenkins/workspace/[email protected]/durable-68e91f76/script.sh: helm: not found
<strong>PIPELINESCRIPT</strong>
Code:
pipeline {
   environment {
       registry = &quot;hemanthpeddi/springboot&quot;
       registryCredential = 'dockerhub'
   }
  agent any
  tools {maven &quot;maven&quot; }
  stages {
    stage('Cloning Git') {
      steps {
        git 'https://github.com/hrmanth/game-of-life.git'
      }
    }
    stage('Build'){
      steps{
           sh script: 'mvn clean package'
         }
       }
    stage('Building image') {
      steps{
        script {
          dockerImage = docker.build registry + &quot;:$BUILD_NUMBER&quot;
        }
      }
    }
    stage('Deploy Image') {
      steps{
         script {
            docker.withRegistry( '', registryCredential ) {
            dockerImage.push()
            }    
          }
        }
      }
    stage('Remove Unused docker image') {
      steps{
        sh &quot;docker rmi $registry:$BUILD_NUMBER&quot;
      }
    }
    stage('Run Helm') {
      steps {
      script {      
      container('helm') {
        sh &quot;helm ls&quot;
       }
      } 
      }
}
}
}
Is there any specific configuration that i'm missing before i use helm in jenkins? And i have configured my kubernetes IP in the <em>cloud configuration</em> in jenkins, Please help
<strong>Plugins Installed</strong>
Kubernetes Plugin
Docker Plugin