How to get a System Groovy Script in Git

13 views
Skip to first unread message

Amedee Van Gasse

unread,
Feb 15, 2021, 4:01:08 PM2/15/21
to Jenkins Users
Someone here at the company wrote a "System Groovy Script" that runs as a nightly job on master.
The code of the script, all 100 lines of it, is directly in the job configuration in the web interface.
I would like to get that code in a git repository, so that it's easy to roll back if needed, and also so that it is easier to read and write when I have the code open in IntelliJ.
What would be a "best practice" to do that?

I see that the Groovy plugin has only two options:
* code directly in the job config
* a groovy file, I assume somewhere in the job workspace, but that isn't specified.
Would I need another configuration before that? In "Source Code Management"?

How would you do it?

Dirk Heinrichs

unread,
Feb 16, 2021, 1:47:04 AM2/16/21
to jenkins...@googlegroups.com
Am Montag, den 15.02.2021, 13:01 -0800 schrieb Amedee Van Gasse:

Would I need another configuration before that? In "Source Code Management"?

Yes. Just add the it repo containing your script there (as you would do in any other job) and change the System Groovy Script step to use the script from there.

HTH...

Dirk
-- 
Dirk Heinrichs
Senior Systems Engineer, Delivery Pipeline
OpenText ™ Discovery | Recommind
Recommind GmbH, Von-Liebig-Straße 1, 53359 Rheinbach
Vertretungsberechtigte Geschäftsführer Gordon Davies, Madhu Ranganathan, Christian Waida, Registergericht Amtsgericht Bonn, Registernummer HRB 10646
This e-mail may contain confidential and/or privileged information. If you are not the intended recipient (or have received this e-mail in error) please notify the sender immediately and destroy this e-mail. Any unauthorized copying, disclosure or distribution of the material in this e-mail is strictly forbidden
Diese E-Mail enthält vertrauliche und/oder rechtlich geschützte Informationen. Wenn Sie nicht der richtige Adressat sind oder diese E-Mail irrtümlich erhalten haben, informieren Sie bitte sofort den Absender und vernichten Sie diese Mail. Das unerlaubte Kopieren sowie die unbefugte Weitergabe dieser Mail sind nicht gestattet.
signature.asc
Reply all
Reply to author
Forward
0 new messages