<p>My groovy pipeline has 3 steps (all with shell):</p>
<ul>
<li><strong>stage 1:</strong> authenticate to GKE cluster and update kubeconfig</li>
<li><strong>stage 2:</strong> helm install on that cluster (using --context)</li>
<li><strong>stage 3:</strong> kubectl wait for condition (using --context)</li>
</ul>
<p>Now most of the time these jobs run fine with no issues at all.
But a few days ago it gave me this error on stage 3:</p>
<p><code>error: context &quot;...&quot; does not exist</code></p>
<p>I can't figure out why this failed once, and unfortunately I don't have the full log of that job any more.
It's weird, as the context worked for the helm install stage, so how could it be not found all of a sudden?</p>
<p>what do you think can cause this random issue? How can I avoid it in the future?</p>

Ariel
<p>The reason is <code>&quot;...&quot;</code> context does not exist in your kubeconfig file. You can run <code>kubectl config view -o jsonpath='{.current-context}'</code> to check current context and use that context.</p>
<p>As per in <a href="https://kubernetes.io/docs/reference/kubectl/cheatsheet/#kubectl-context-and-configuration" rel="nofollow noreferrer">this document</a> Set which Kubernetes cluster kubectl communicates with and modifies configuration information.</p>
