5

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.

Here is the method:

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..."
        }
}

Here is the error i get when i execute this code:

The current scope already contains a variable of the name rc
 @ line 148, column 13.
           def rc = sh(script: """
               ^

Does anyone know what could be the issue?

Omri
  • 1,436
  • 7
  • 31
  • 61

0 Answers0