2
votes

I have been trying to deploy the image built on jenkins by docker to helm charts, i have referred couple of documents on website https://dev.to/sword-health/seamless-ci-cd-with-jenkins-helm-and-kubernetes-5e00 and https://cloudcompilerr.wordpress.com/2018/06/03/docker-jenkins-kubernetes-run-jenkins-on-kubernetes-cluster/ 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.

JENKINS ERROR

+ helm list
/var/lib/jenkins/workspace/01@tmp/durable-68e91f76/script.sh: 1: /var/lib/jenkins/workspace/01@tmp/durable-68e91f76/script.sh: helm: not found

PIPELINESCRIPT

pipeline {
   environment {
       registry = "hemanthpeddi/springboot"
       registryCredential = 'dockerhub'
   }
  agent any
  tools {maven "maven" }
  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 + ":$BUILD_NUMBER"
        }
      }
    }
    stage('Deploy Image') {
      steps{
         script {
            docker.withRegistry( '', registryCredential ) {
            dockerImage.push()
            }    
          }
        }
      }
    stage('Remove Unused docker image') {
      steps{
        sh "docker rmi $registry:$BUILD_NUMBER"
      }
    }
    stage('Run Helm') {
      steps {
      script {      
      container('helm') {
        sh "helm ls"
       }
      } 
      }
}
}
}

Is there any specific configuration that i'm missing before i use helm in jenkins? And i have configured my kubernetes IP in the cloud configuration in jenkins, Please help

Plugins Installed

Kubernetes Plugin

Docker Plugin

3
Did you fix that?Ali-Alrabi

3 Answers

1
votes

You need helm, it is not available by default. You could add helm as a tool in Jenkins and use it. https://www.jenkins.io/doc/book/pipeline/syntax/#tools

0
votes

I am not so familiar with that, but when you are using the "container('helm')" step, I think it refers to Kubernetes Plugin.
So, reading this docs, I think that the "podTemplate" is missing in your configuration.
Thus what you need to do is to configure a Helm container in the "podTemplate" and put the name "helm". You can try to use, for example, the "alpine/helm" image. See you later.

0
votes

you can install helm in the container itself by adding an extra stage

 stage("install helm"){
    steps{
         sh 'wget https://get.helm.sh/helm-v3.6.1-linux-amd64.tar.gz'
         sh 'ls -a'
         sh 'tar -xvzf helm-v3.6.1-linux-amd64.tar.gz'
         sh 'sudo cp linux-amd64/helm /usr/bin'
         sh 'helm version'
    }
}