Search code examples
groovyjenkins-groovy

Escape character in Groovy to AnsibleTower


During passcode transfer from groovy script to ansible tower plugin, is there any way to send passcode with special character with slash "<passcode>"

ansibleTower(async: false, credential: 'test_cred', extraVars: """
---
password: "U*gLO8br1dMJ\y!U"
"""

While passing a special character it is not able to read the passcode. Is there any regular expression to send this special character

 Unable to request job template invocation Extra vars are bad: ["Cannot parse as JSON (error: Expecting value: line 2 column 1 (char 1)) or YAML (error: while scanning a double-quoted scalar\n  in \"<unicode string>\", line 4, column 16:\n    sudo_password: \"U*gLO8br1dMJ\\y!U\"\n                   ^\nfound unknown escape character 'y'\n  in \"<unicode string>\", line 4, column 30:\n    sudo_password: \"U*gLO8br1dMJ\\y!U\"\n                                 ^)."]

Solution

  • Adding an extra "\" in the password will suffice to escape the password. Like "U*gLO8br1dMJ\\y!U" will suffice