As others have said, strictly speaking you cannot alter environment variables of the running processs.
However, assuming you want to "do something like getenv" in order to get the values of certain variables following execution of your script, you can do something like this:
def map = [:]
def envAsText = ['sh', '-c', 'source myfile.conf 2>&1 >/dev/null && env'].execute().text
envAsText.eachLine { (key,value) = it.split('=', 2); map[key] = value }
This creates an empty map, then executes child process to "source" your file, filter out all output while sourcing, then print environment with "env" command. (also assuming unix-like system, which is implied from your "myfile.conf"). Finally, output is collected and stored to "map".
After this, "map" contains all environment of your child process (now finished), including "variable2":
map['variable2'] // this contains "Value2"