<p>I have created a EC2 instance where Jenkins is running connected to my GitHub account. The following are the two steps of my Jenkins pipeline:   </p>

<pre><code>pipeline {
    agent any
    stages {
        stage('Kubernetes cluster') {
            steps {
                withAWS(region:'us-west-2', credentials:'aws-kubernetes') {
                    sh '''
                    if [ ! aws cloudformation describe-stacks --region us-west-2 --stack-name eksctl-EmaJarK8sCluster-cluster ] ; then

                        if [ ! aws cloudformation describe-stacks --region us-west-2 --stack-name eksctl-EmaJarK8sCluster-nodegroup-standard-workers ] ; then

                            eksctl create cluster \
                            --name EmaJarK8sCluster \
                            --version 1.13 \
                            --nodegroup-name standard-workers \
                            --node-type t2.small \
                            --nodes 2 \
                            --nodes-min 1 \
                            --nodes-max 3 \
                            --node-ami auto \
                            --region us-west-2 \
                            --zones us-west-2a \
                            --zones us-west-2b \
                            --zones us-west-2c \

                        fi

                    fi
                    '''
                }
            }
        }

        stage('Configuration file cluster') {
            steps {
                withAWS(region:'us-west-2', credentials:'aws-kubernetes') {
                    sh '''
                        aws eks --region us-west-2 update-kubeconfig --name EmaJarK8sCluster
                    '''
                }
            }
        }
    }
}
</code></pre>

<p>The first step creates a Kubernetes cluster if it doesn't exist, the second one creates a configuration file for that cluster. This step works pretty well and creates two cloudformation stacks and one EC2 machine where the Kubernetes cluster is running.</p>

<p>The second stage fails with the following error:</p>

<pre><code>Invalid choice: 'eks', maybe you meant:

  * es
</code></pre>

<p>After reading a couple of tutorial I've found out that I needed to update <code>awscli</code> to version <code>1.18.57</code> in order to have the <code>eks</code> command available. So I've logged into my Jenkins machine (not the one dedicated to the k8s cluster) ad I've update the <code>awscli</code>. 
Unfortunately this is not enough. I still get the same error. I can run the command manually into Jenkins the machine but, for some reason, I cannot run it via Jenkins pipeline.</p>

<p>Can someone help me with this problem?</p>

<p>Thanks in advance.</p>

<p>Are you updated <code>jenkins</code> agents?</p>

<p>If not:</p>

<p><a href="https://github.com/jenkinsci/windows-slave-installer-module#upgrading-old-agents" rel="nofollow noreferrer">Upgrading Windows Service Wrapper</a></p>

<blockquote>
  <ol>
  <li>Upgrade Jenkins to the version, which provides this module</li>
  <li>Jenkins is expected to automatically upgrade <code>jenkins-slave.exe</code> executables </li>
  <li>If the upgrade happens, you should be able to see the message in the <code>Agent log</code> in Jenkins Web UI</li>
  <li>Once upgrade is done, the changes will be applied on the next Windows service restart</li>
  </ol>
</blockquote>
