We\'re upgrading to a newer version of Jenkins (2.60.1) and a groovy script which was working in the previous Jenkins version (1.596/2) no longer works.
This is a Je
Please double check that jenkins is not blocking this import. Go to script approvals and check to see if it is blocking it. If it is click allow.
https://jenkins.io/doc/book/managing/script-approval/
As pointed out by @Jayan in another post, the solution was to do the following
import jenkins.model.*
jenkins = Jenkins.instance
Then I was able to do the rest of my scripting the way it was.
For me this problem occurred because I had a some invalid character in my Groovy script. In our case this was an extra blank line after the closing bracket of the script.
in my case I have used -
(Hyphen) in my script name in case of Jenkinsfile Library.
Got resolved after replacing Hyphen(-) with Underscore(_)