I've managed to implement something that is effectively the same. I realized that I can define a class in "src" that is just a static data container and can be accessed from any of the "vars" scripts.
On Thursday, September 16, 2021 at 1:21:10 PM UTC-7 David Karr wrote: > > I work on a somewhat complicated build process using Jenkins scripted > pipeline, where the Jenkinsfile is very small, but it imports a large > shared library, sets some application-specific properties, and then calls a > top-level function in the "vars" section of the shared library. > > The top-level function is pretty complicated, and it calls a bunch of > other "var" functions. Data is passed to those functions through "env." > vars, and function parameters. > > I am working on some changes to one of the lower-level functions, where it > will reference a couple of "statically-defined" map objects that specify > some metadata about build steps. > > Initially, I simply defined those maps inside the "call()" function in the > "vars" file. That does work. However, I see that there is more than one > "vars" file that needs to reference those maps. > > It would make sense if I could move these map definitions to the top-level > "vars" file, I assume right inside the "call()" function (or somewhere > else, if that makes sense) and then reference them inside the "vars" > functions that need that data. > > If these were scalar values, I would just set "env.<variablename> = > <value>" in the top-level "vars" file, inside the "call()" function, and > then reference that environment variable in the lower-level "vars" file. > Can I set a Map object into environment variables? I wouldn't think it > would allow that. > > I technically could simply reference the variable name in the top-level > "vars" function, and pass it down through the layers, but that gets messy. > I'd prefer to reference these maps like "static" variables (conceptually if > not in actuality) in the lower-level "vars" file. > > I have browsed the documentation, but I haven't seen an obvious way to do > this. > -- You received this message because you are subscribed to the Google Groups "Jenkins Users" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. To view this discussion on the web visit https://groups.google.com/d/msgid/jenkinsci-users/222db998-b989-4528-afc8-c2c8e16152c7n%40googlegroups.com.
