According to the documentation, you can also set global environment variables if you later want to use the value of the variable in other parts of your script. In your case, it would be setting it in the root pipeline:
pipeline {
...
environment {
FILENAME = readFile ...
}
...
}