Home > Enterprise >  Jenkins pipeline: kubectl command not found
Jenkins pipeline: kubectl command not found

Time:01-11

I'm running Jenkins locally and this is the last stage of my Jenkinsfile (after following this enter image description here

The copy before the apply command is working. I have microk8s installed on the Debian server I'm trying to deploy to and if I run the apply command manually then it's working fine. I've created the .kube/config file as shown enter image description here

What can I do here to make the apply work from the pipeline?

CodePudding user response:

In this situation where the error thrown is that the executable command is not found in the path, then the absolute path should be attempted as a first step. The shell step method can be updated accordingly:

sh 'ssh <user>@<ip_address> /path/to/kubectl apply -f /opt/kubernetes-system/backend/deployment-remes-be.yaml --kubeconfig=~/.kube/config'
  • Related