0

I experienced a weird Jenkins error while trying to run a groovy-scripted pipeline that contained backslashes inside comments.

Here is the offending code:

// The script below depends on:
// * The presence of a recent nuget.exe in c:\tools (v5.7)
// * The presence of the xxx plugin installed for user foo\username

I'm aware the backslash is used in many languages to start an escape sequence, but I had never before experienced backslashes being an issue inside comments.

I wonder if this backslash in comments behavior is due to Groovy itself or rather a bug in the way Jenkins interprets it...

Edit: I solved my issue by replacing the offending \ with \\ but then noticed I had forgotten to double the backslash in c:\tools, and still Jenkins did not complain. It seems Jenkins (or Groovy) tried to interpret the \u in foo\username as introducing an hex character code... but was okay with \t for it probably was interpreted as a tab!

odalet
  • 1,259
  • 10
  • 17
  • 1
    The same thing applies to Java https://stackoverflow.com/a/30727799/6509 Unicode parsing happens prior to parsing the code – tim_yates Sep 01 '20 at 10:03
  • Then neither Groovy nor Jenkins fault, but deep in Java... Thanks! You should turn this comment into the answer! – odalet Sep 01 '20 at 10:18

0 Answers0