Skip to content

Instantly share code, notes, and snippets.

@frezbo
Forked from alces/SetBuildEnvVars.groovy
Created August 21, 2018 11:28
Show Gist options
  • Save frezbo/b40eeca4b00f934009a510a446fff9df to your computer and use it in GitHub Desktop.
Save frezbo/b40eeca4b00f934009a510a446fff9df to your computer and use it in GitHub Desktop.
Set environment variables during a Jenkins build using Groovy
// should be run as Groovy System Script
import hudson.EnvVars
import hudson.model.Environment
def build = Thread.currentThread().executable
def vars = [ENV_VAR1: 'value1', ENV_VAR2: 'value2']
build.environments.add(0, Environment.create(new EnvVars(vars)))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment