Setting worker process environment variables from event plugin

Hello, I’m trying to sort out this issue before it comes up in our pipeline.

At the moment I have an Event plugin that sets some environment variables for jobs when they are submitted to setup our pipeline tools. This works right now as all of our workers are Windows based. In the near future we hope to implement some cloud workers and these may or may not be running Windows. In any case, these environment variables will need to be set based on the platform the worker is running on. The tool we use to manage our environment variables handles this just fine, but I’m trying to figure out the best place to actually set the worker process environment variables.

Is it possible to use my Event plugin to set environment variables per worker process? Maybe through the OnSlaveStartingJob callback?

From what I’ve read I could probably tackle this in a GlobalJobPreLoad script. However, I’m a big fan of how Event plugins are configured through param files and I can include python dependencies within the plugin folder. It’s nice and contained and I can deploy the plugin through a git clone, git pull.

OnSlaveStartingJob can work, though OnSlaveStarted might be better if you’re looking to set variables that are Job agnostic.

If the variables you’re setting are going to be Job specific you’ll have to use OnSlaveStartingJob as that gets a copy of the Job object that you can query.