title: Jenkins pipeline groovy string compare
body: <p>When I use Jenkins pipeline through with Docker, I want to compare string value with Groovy script, but the compare result was wrong, the follow script is my groovy script and the output result:</p>
  
  <p>Is there anyone can tell me how resolve this problem?</p>
  
  <pre><code>String runningContainerId = sh(script: "docker ps --filter=\"name=${appEnv}-${env.JOB_NAME}-${env.BUILD_NUMBER}\" -q | xargs", returnStdout: true)
  //def runningImageId = sh(script: "docker images | grep ${appEnv}-${env.JOB_NAME}:${env.BUILD_NUMBER} | tr -s ' ' | cut -d ' ' -f 3 ", returnStdout: true)
  
  println 'current container:' + runningContainerId
  //println runningImageId
  try{
  def ret = sh(script: "docker ps --filter=\"name=${appEnv}-${env.JOB_NAME}\" -q | xargs", returnStdout: true)
  def splitStr = ret.tokenize(" ")
  println 'splitStr=&gt;' + splitStr
  String containerId = runningContainerId
  println 'containerId=&gt;' + containerId
  
  for( String str in splitStr) {
      print str == containerId
      print 'str=&gt;' + str
       if ( str == containerId) {
          print 'same string:' + str 
       } else {
          print 'different string:' + str
       }
  }
  </code></pre>
  
  <p>Jenkins output result is:</p>
  
  <pre><code>splitStr=&gt;[8abe81071b7f, 40e2292d5099, 4136bbdf9cc5]
  [Pipeline] echo
  containerId=&gt;8abe81071b7f
  
  [Pipeline] echo
  false
  [Pipeline] echo
  str=&gt;8abe81071b7f
  [Pipeline] echo
  different string:8abe81071b7f
  [Pipeline] echo
  false
  [Pipeline] echo
  str=&gt;40e2292d5099
  [Pipeline] echo
  different string:40e2292d5099
  [Pipeline] echo
  false
  [Pipeline] echo
  str=&gt;4136bbdf9cc5
  
  [Pipeline] echo
  different string:4136bbdf9cc5
  </code></pre>