Environment Modules (modulefile) integration into Jenkins Pipeline (Groovy)?

360 Views Asked by At

I am deploying Environment Modules here at my company and would like to make sure that all use models are covered adequately. Since Groovy is not a supported language by modulecmd.tcl, and tampering with the code base is not an option, I'm wondering what would be simplest way to expose an environment to a Jenkins executor that is based on source $(module load <modulefile>) (BASH)?

Some possibilities:

  1. write a translator for stdout of subprocess .../modulecmd.tcl bash <modulefile>
  2. write a translator for stdout of subprocess module load <modulefile> | env; would need to do some diff'ing to support unload
  3. plugin?

I've looked at "environment script" and "environment injector" plugins but can't test these w/o upgrading Jenkins (plugins are not compatible). I got the impression scripts are supported but would have to output in specific format (more code to write).

Has anyone here been able to integrate Env Modules into a Pipeline, or could give some guidance as to best practice when needing to import an environment that is natively based on sourcing script output that is shell/interpreter specific?

1

There are 1 best solutions below

0
On

There is a ticket for Groovy support in Environment Modules now: https://github.com/cea-hpc/modules/issues/446