title: Error in Groovy script: The current scope already contains a variable
body: <p>I'm trying to write a groovy method for Jenkins pipeline. The method gets two variables, put them inside a string, and execute the string as a shell command.</p>
  
  <p>Here is the method:</p>
  
  <pre><code>def method(A, B) {
          test = "cp app/scripts/" + A + "config." + B + "js app/scripts/config.js"
  
          def rc = sh(script: test, returnStatus: true)
          if (rc != 0) {
              error "Failed, exiting now..."
          }
  }
  </code></pre>
  
  <p>Here is the error i get when i execute this code:</p>
  
  <pre><code>The current scope already contains a variable of the name rc
   @ line 148, column 13.
             def rc = sh(script: """
                 ^
  </code></pre>
  
  <p>Does anyone know what could be the issue?</p>