How to import a groovy script present in a different folder into another groovy script

4,761 views
Skip to first unread message

Srini

unread,
Apr 21, 2015, 3:13:15 PM4/21/15
to job-dsl...@googlegroups.com
Hi , 

Am looking for some help with the groovy script. I have a groovy script in a folder and my requirement is to import this groovy script into another groovy script present in a different folder. Can someone help me with this? 

Thanks,
Srini

Daniel Spilker

unread,
May 4, 2015, 9:19:55 AM5/4/15
to job-dsl...@googlegroups.com

--
You received this message because you are subscribed to the Google Groups "job-dsl-plugin" group.
To unsubscribe from this group and stop receiving emails from it, send an email to job-dsl-plugi...@googlegroups.com.
To post to this group, send email to job-dsl...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/job-dsl-plugin/37f191af-dd43-4924-bbd3-b1caf000c51a%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Srini

unread,
May 4, 2015, 11:08:13 AM5/4/15
to job-dsl...@googlegroups.com
Hi Daniel, 

Thanks for the update. Have one more question

As per the Wiki page it says i need to make a directory at the same level as the DSL called. This is good as long as if i have only one directory. As per this if i have multiple directories with different DSLs then if i want to import the same DSL in all scripts , i need to copy the same in all directories . Is there any way to copy the DSL in one common location and call the script from different DSL scripts present in different directories? Please advise.

Thanks,
Srini

Daniel Spilker

unread,
May 4, 2015, 11:17:00 AM5/4/15
to job-dsl...@googlegroups.com
In that case, have a look at the Job DSL Gradle Example Workspace: https://github.com/sheehan/job-dsl-gradle-example

The workspace contains the support classes in src/main/groovy. These classes can be used from any location when settings the additional classpath option of the "Process Job DSLs" step to src/main/groovy. It should work without Gradle, but you can use Gradle to run tests for your support classes. You can also replace Gradle by your favorite Java build tool...

If you want to package and publish your support classes in a JAR, have a look at this wiki entry: https://github.com/jenkinsci/job-dsl-plugin/wiki/User-Power-Moves#using-libraries

Daniel

--
You received this message because you are subscribed to the Google Groups "job-dsl-plugin" group.
To unsubscribe from this group and stop receiving emails from it, send an email to job-dsl-plugi...@googlegroups.com.
To post to this group, send email to job-dsl...@googlegroups.com.
Reply all
Reply to author
Forward
0 new messages