Calling Other Groovy Files and All Groovy Files in a Directory from build.groovy – Example
This article explains how to invoke other Groovy scripts and all Groovy files within a directory from a build.groovy file, providing concrete example code that demonstrates calling a Print method in hello.groovy and using it inside mytools.groovy.
The problem asks how to define calls from build.groovy to other xxx.groovy files and to all xxx.groovy files in a directory, and requests a working example.
Below is an example where mytools.groovy calls the Print() method defined in hello.groovy :
package org.devops def Print(){ println("hello") }
The calling script mytools.groovy creates an instance of the hello class and invokes its Print() method:
package org.devops def sayHello(){ def hello = new hello() hello.Print() }
DevOps Cloud Academy
Exploring industry DevOps practices and technical expertise.
How this landed with the community
Was this worth your time?
0 Comments
Thoughtful readers leave field notes, pushback, and hard-won operational detail here.