Putting your script in the Jenkins configuration is fine, but there is an alternative, the Jenkinsfile. The Jenkinsfile is simply a file in your Git repository that contains the pipeline script you want to run. So, copy the pipeline script and place it in a file named Jenkinsfile (no extension) in the root of your repository and commit it to Git. Now, go to the configuration of your pipeline project and change the definition from Pipeline script to Pipeline script from SCM. You must now pick your SCM, which is Git, and then configure the connection to your repository. This works exactly the same as in freestyle projects. Additionally, there is a Script Path, which defaults to Jenkinsfile and Lightweight checkout, which you can leave checked. Again, save and run the project and, basically, everything will be like before, except your script is now in your repository...
Germany
Slovakia
Canada
Brazil
Singapore
Hungary
Philippines
Mexico
Thailand
Ukraine
Luxembourg
Estonia
Lithuania
Norway
Chile
United States
Great Britain
India
Spain
South Korea
Ecuador
Colombia
Taiwan
Switzerland
Indonesia
Cyprus
Denmark
Finland
Poland
Malta
Czechia
New Zealand
Austria
Turkey
France
Sweden
Italy
Egypt
Belgium
Portugal
Slovenia
Ireland
Romania
Greece
Argentina
Malaysia
South Africa
Netherlands
Bulgaria
Latvia
Australia
Japan
Russia