<p>I have an Azure cloud where a Kubernetes cluster was created by me. Besides, in my environment, I have Jenkins running for the pipeline. I need to create a container with React FE in it. I need to describe some kubectl commands with kubeconfig to enable access to Kubernetes clusters in my Azure cloud. Below lines of code are from the Jenkins groovy file:</p>
<pre><code>sh &quot;helm template $podPath -f $destPath --set namespace=$namespace &gt; helm_chart_${env}.yaml&quot; sh &quot;kubectl config set-context jenkins-react@react --kubeconfig=/root/.kube/sa_new_kubeconfig&quot; sh &quot;kubectl delete -f helm_chart_${env}.yaml
--kubeconfig=/root/.kube/sa_new_kubeconfig || true&quot; sh &quot;sleep 10&quot;
</code></pre>
<p>I am willing to know if there is any alternative way to use kubeconfig apart from defining it explicitly in Jenkins groovy code. If yes then which is the convenient and better way?</p>

UnicsSol
<p>You can use an env variable <code>KUBECONFIG</code> with the path to your Kubernetes config file.</p>
<p>Then, it depends on how you configure your Jenkins and your Jenkins pipeline, but you may:</p>
<ul>
<li>Add this variable to your Jenkins agent configuration</li>
<li>Add this variable to your Jenkinsfile pipeline</li>
</ul>
