<p>I write this function</p>
<pre><code>def docker_images(image_name,image_tag){

def curl_image_exists_status_code =

    curl_image_exists_status_code=sh (
    script:&quot;&quot;&quot; docker login -u XXXXX -p $$$$$$  2&gt; /dev/null 1&gt;/dev/null
    docker pull XXXXX/'${image_name}':'${image_tag}' &gt; /dev/null &amp;&amp; echo &quot;success&quot; || echo 'failed' 
    &quot;&quot;&quot;,  returnStdout: true)
    echo &quot;${curl_image_exists_status_code}&quot;
    return (curl_image_exists_status_code == 'success')?true: false
    }
</code></pre>
<p>but the output is</p>
<blockquote>
<p>success</p>
<p>null</p>
</blockquote>
<p>and the last line returns <code>false</code>
the output of <code>curl_image_exists_status_code</code> should be success and the last line should return true
but why it is not working?</p>

lovecode
<p>try </p>

<pre><code>def docker_images(image_name,image_tag){

def curl_image_exists_status_code=sh (
    script:""" docker login -u XXXXX -p $$$$$$  2&gt; /dev/null 1&gt;/dev/null
    docker pull XXXXX/'${image_name}':'${image_tag}' &gt; /dev/null &amp;&amp; echo "success" || echo 'failed' 
    """,  returnStdout: true)
    echo "${curl_image_exists_status_code}"
    return (curl_image_exists_status_code == 'success')?true: false
    }
</code></pre>
