Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support for Annotation BaseScript #104

Open
obfischer opened this issue Jun 18, 2021 · 1 comment
Open

Support for Annotation BaseScript #104

obfischer opened this issue Jun 18, 2021 · 1 comment
Labels
enhancement New feature or request

Comments

@obfischer
Copy link
Contributor

Desired Behavior

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.

  1. Allows to use more features provided by Groovy to write better pipeline code
  2. Better support for standard features of Groovy supported also by Jenkins
@haridsv
Copy link

haridsv commented Jun 20, 2021

@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.

@awittha awittha added the enhancement New feature or request label Aug 17, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Development

No branches or pull requests

3 participants