I have added helm as podtemplate in value.yaml file
podTemplates:
helm: |
- name: helm
label: jenkins-helm
serviceAccount: jenkins
containers:
- name: helm
image: lachlanevenson/k8s-helm:v3.1.1
command: "/bin/sh -c"
args: "cat"
ttyEnabled: true
privileged: true
resourceRequestCpu: "400m"
resourceRequestMemory: "512Mi"
resourceLimitCpu: "1"
resourceLimitMemory: "1024Mi"
so i want to run helm in pipeline as
steps {
container('helm') {
sh "helm upgrade --install --force ./helm"
}
}
but i got error
/home/jenkins/workspace/coverwhale@tmp/durable-4d1fbfd5/script.sh: 1: /home/jenkins/workspace/coverwhale@tmp/durable-4d1fbfd5/script.sh: helm: not found
Version of Helm and Kubernetes:
Helm Version:
$ helm version
version.BuildInfo{Version:"v3.5.2", GitCommit:"167aac70832d3a384f65f9745335e9fb40169dc2", GitTreeState:"dirty", GoVersion:"go1.15.7"}
Kubernetes Version:
$ kubectl version
Client Version: version.Info{Major:"1", Minor:"20", GitVersion:"v1.20.2", GitCommit:"faecb196815e248d3ecfb03c680a4507229c2a56", GitTreeState:"clean", BuildDate:"2021-01-13T13:28:09Z", GoVersion:"go1.15.5", Compiler:"gc", Platform:"linux/amd64"}
Server Version: version.Info{Major:"1", Minor:"20", GitVersion:"v1.20.2", GitCommit:"faecb196815e248d3ecfb03c680a4507229c2a56", GitTreeState:"clean", BuildDate:"2021-01-13T13:20:00Z", GoVersion:"go1.15.5", Compiler:"gc", Platform:"linux/amd64"}
Which version of the chart:
What happened: /home/jenkins/workspace/coverwhale@tmp/durable-4d1fbfd5/script.sh: 1: /home/jenkins/workspace/coverwhale@tmp/durable-4d1fbfd5/script.sh: helm: not found
What you expected to happen: run helm chart
<!-- This could be something like: values.yaml (only put values which differ from the defaults) ``` key: value ``` ``` helm install my-release jenkins/jenkins --version version --values values.yaml ``` -->pipeline code
pipeline {
agent any
stages {
stage('Initialize Docker'){
steps {
script {
def docker = tool 'whaledocker'
echo "${docker}"
echo "${env.PATH}"
env.PATH = "${docker}/bin:${env.PATH}"
echo "${env.PATH}"
}
}
}
stage('Checkout Source') {
steps {
git url:'https://github.com/alialrabi/laravel-example.git', branch: 'uat', credentialsId: 'github'
}
}
stage("Build image") {
steps {
script {
myapp = docker.build("alialrabi/coverwhale:${env.BUILD_ID}")
}
}
}
stage("Run Test") {
steps {
script {
docker.image("alialrabi/coverwhale:${env.BUILD_ID}").inside {
// sh 'composer install'
// sh 'php artisan test'
}
}
}
}
stage("Push image") {
steps {
script {
docker.withRegistry('https://registry.hub.docker.com', 'dockerhub') {
myapp.push("latest")
myapp.push("${env.BUILD_ID}")
}
}
}
}
stage('Deploy Uat') {
steps {
script {
echo "Done Uat"
sh "helm upgrade --install --force"
}
}
}
}
}
you can install helm on the instance as well in which you are running your jenkins pipeline
stage("helm install"){
steps{
echo "Helm install"
sh 'curl -o kubectl https://amazon-eks.s3.us-west-2.amazonaws.com/1.18.9/2020-11-02/bin/linux/amd64/kubectl'
sh 'curl -LO "https://dl.k8s.io/release/$(curl -L -s https://dl.k8s.io/release/stable.txt)/bin/linux/amd64/kubectl" '
sh 'sudo cp kubectl /usr/bin'
sh 'sudo chmod +x /usr/bin/kubectl'
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'
}
}
I have solved it by add containerTemplate to agent.
stage('Deploy dev') {
agent {
kubernetes {
containerTemplate {
name 'helm'
image 'lachlanevenson/k8s-helm:v3.1.1'
ttyEnabled true
command 'cat'
}
}
}
steps {
container('helm') {
sh "helm upgrade full-cover ./helm"
}
}
}