I am trying to write a jenkins build script for my project in Groovy. the problem is that I want to define some variables at the top of the script and use them when I want as Environment variable.
def someVariable = 'foo'
pipeline{
agent any
stages{
stage("build"){
environment {
specialParameter = someVariable
}
steps{
...
}
}
...
}
}
I have some other steps that their environment variables are different and also I want to just change the top of the script to able to build other branches and so on. so I just want a way to use the defined someVariable in the environment body.
Thanks