I have Jenkinsfile like this:
def globalVariable = "my variable"
def myFunction() {
def myString = "my String and ${globalVariable}
.....
}
pipeline {
...
< The globalVariable can be accessed inside the pipeline >
}
I receives a runtime error, complaining globalVariable cannot be accessed inside the myFunction.
I thought globalVariable is global and can be accessed anywhere from the file.
Is there anyway I can reference it inside function?