Forum Discussion

zorglups's avatar
zorglups
Occasional Contributor
5 years ago
Solved

Property Expansion Dynamic Expression issue with brace character.

Here is my Property Dynamic Expression:

${= use (groovy.time.TimeCategory) {2.years.from.now.format('yyyy-MM-dd')}}

 

Upon evaluation, this trows this error:

startup failed:
Script47.groovy: 1: expecting '}', found '' @ line 1, column 71.
.from.now.format('yyyy-MM-dd')
^
org.codehaus.groovy.syntax.SyntaxException: expecting '}', found '' @ line 1, column 71.
at org.codehaus.groovy.antlr.AntlrParserPlugin.transformCSTIntoAST(AntlrParserPlugin.java:143)

Well. I understand that I cannot use braces but then how can I achieve my goal ?

Isn't there a way to escape the braces ?

 

Thank you.

Pierre

  • Hi zorglups,

    The following script works fine for me:

    use(groovy.time.TimeCategory){"${2.years.from.now.format('yyyy-MM-dd')}"}

    But it seems there is no way to use it in property expansions directly because of its complexity. Instead, you can try to place the script inside some Groovy test step, and then extract its result by using this property expansion:
    ${Groovy Script#result}

    How does it work for you?

7 Replies

  • nmrao's avatar
    nmrao
    Champion Level 3
    Oh I remember now. I believe the tool don't like inline braces "{" and "}" aparart from "${..}"
    • zorglups's avatar
      zorglups
      Occasional Contributor

      Thank you for replying.

      What other detail do you need on top of the ${} bloc used for the property definition, provided in my initial question ?

      I'm specifically asking how to escape brace or any work-around to achieve the same as per my groovy oneliner:

      Well. I understand that I cannot use braces but then how can I achieve my goal ?

      Isn't there a way to escape the braces ?




      • nmrao's avatar
        nmrao
        Champion Level 3
        I was quick early, sorry about it. Hope you might saw the 2nd reply. As per my knowledge, it will not parse if expression contains inline flower braces.
  • nmrao's avatar
    nmrao
    Champion Level 3
    Please provide more info inorder to enable to look into the problem.