You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Groovy scripts and therefore Jenkins variables, to inherit automatically from the class CpsScript. Using the annotation BaseScript in a script allows to advice the Groovy compiler to use a different class as base class for the script.
This functionality can be quite useful, if you have scripts with nearly identical behaviour. In such a case you can move the common functionality to a abstract class, which inherits from CpsScript and use this class as base class for the Groovy script instead of the standard one.
Currently the library is unable to test such scripts, but it would be good to be able to test such scripts too.
Benefits
Please list the benefits of updating the project to have the new behavior, e.g.
Allows to use more features provided by Groovy to write better pipeline code
Better support for standard features of Groovy supported also by Jenkins
The text was updated successfully, but these errors were encountered:
@obfischer We do use this same technique and unit test them using JenkinsPipelineUnit. I had to repeat some of the setup for intercepting methods that the framework normally does while loading the scripts. I haven't used jenkins-spock framework myself, but I imagine it does something similar to JenkinsPipelineUnit and encourage you to follow the path of loadPipelineScriptForTest and see what interceptors are being setup and repeat them in your test framework.
Desired Behavior
Groovy scripts and therefore Jenkins variables, to inherit automatically from the class
CpsScript
. Using the annotationBaseScript
in a script allows to advice the Groovy compiler to use a different class as base class for the script.This functionality can be quite useful, if you have scripts with nearly identical behaviour. In such a case you can move the common functionality to a abstract class, which inherits from
CpsScript
and use this class as base class for the Groovy script instead of the standard one.Currently the library is unable to test such scripts, but it would be good to be able to test such scripts too.
Benefits
Please list the benefits of updating the project to have the new behavior, e.g.
The text was updated successfully, but these errors were encountered: