tcWebHooks icon indicating copy to clipboard operation
tcWebHooks copied to clipboard

Add ability to include common code into velocity templates

Open netwolfuk opened this issue 5 years ago • 4 comments

There should be a way to "include" code in a velocity template.

Currently any macros need to be added to the top of every event template.

Velocity supports including other files, I just need to figure out a way to do with without actual files.

netwolfuk avatar Jul 11 '19 05:07 netwolfuk

Incudes could simply appear like normal buildstate templates, but have a type to identify them as such, and an ID so they can be included by reference.

netwolfuk avatar Jul 11 '19 05:07 netwolfuk

Would it be possible to share macros and use them without defining them in the template self?

Super8film87 avatar Aug 03 '23 12:08 Super8film87

@Super8film87 where do you imagine they would be stored if not in the template?

Would you want macros available to multiple templates? I've been thinking about this and haven't come up with an elegant solution for that.

netwolfuk avatar Aug 03 '23 14:08 netwolfuk

So right now I work on a centralized template for all our projects -> single source & send all data to elasticsearch (thats the reason why I send all parameters)

-> sharing macros could enable to share same data over multiple templates e.g. product ,infra, dev -> more modularity to the needs of the different users. Also possible to create a modular template with macros

{
"template_id2" : "DevTemplate", //custom
#add.BuildMeta() //refers to other template BuildMeta
#add.AgentMeta() //refers to other template AgentMeta
"triggered_by": "${triggeredBy}"
}

Super8film87 avatar Aug 03 '23 15:08 Super8film87