| You cannot do something like this:
notify { "hello ${Deferred('pid', [])}": }
|
and expect that to have a title that is resolved on the agent - that is the id of the notify - it must be known when compiling. You can also not do this:
notify { "test": message => "hello ${Deferred('pid', [])}" }
|
And expect that the entire message string is resolved and then formatted on the agent side. To be clear why this is the case; consider the semantics of string interpolation: "evaluate an expression, transform to string, and concatenate" - thus, when an instance of Deferred is interpolated it will naturally be transformed to its string form. Thus, a Deferred inside of interpolation, (or inside an EPP template for that matter) will not mean that the string/template is resolved on the agent side. You can do like in this example to make it work:
notify { "test": message => Deferred('sprintf', [ 'hello %d', Deferred('pid', [])]) }
|
or, use EPP:
notify { "test": message => Deferred('inline_epp', [ 'hello <%= pid([]) %> ' ]) }
|
That works because the wanted result is a string - for something that should return something that is not a string, the approach above must be used. Agree this should be pointed out - it will probably be a common thing that people wonder how to do. |