<p>In this Jenkin stage, I am trying to get the pod status and if the status is "TRUE" it will move to the next stage else wait for it.</p>

<pre><code>      node('master'){
           withEnv(["KUBECONFIG=${JENKINS_HOME}/.kube/config"]){
                POSTGRES_CMD= """while [[ \$(kubectl get  pods -l app=postgres-${NAME_SPACE} -o 'jsonpath={..status.conditions[?(@.type=="Ready")].status}' -n ${NAME_SPACE}) != "True" ]]; do echo "waiting for pod" &amp;&amp; sleep 1;done"""
                echo "${POSTGRES_CMD}"
                READY_POD = sh (
                        script: "${POSTGRES_CMD}",
                        returnStdout: true
                  ).trim()
                 echo "${READY_POD}"
</code></pre>

<pre><code>Error:- /var/lib/jenkins/workspace/k8s@2@tmp/durable-95fdd/script.sh: [[: not found
</code></pre>

me25
<p>POSIX <code>sh</code> supports single bracket conditionals: <code>[]</code>. You should be fine using <code>$()</code> for command substitution, in some environment you might need to use back ticks `</p>

<pre><code>while [ "`echo \"true\"`" == "true" ]; do
  sleep 1
done
</code></pre>

<p>In any case, <code>kubectl</code> supports running that wait loop for you:</p>

<pre><code>kubectl wait pods --for=condition=Ready -l app=postgres-${NAME_SPACE} -n ${NAMESPACE} --timeout=60s
</code></pre>
