-
Notifications
You must be signed in to change notification settings - Fork 402
Description
Hello!
First of all please let me congratulate for this awesome tool, after finding it, my workflow for developing Shared Libraries and Jenkins pipelines has changed for the best, so big kudos to the people working on this, it's amazing!
The company that I work for is using this library heavily (I'm the one pushing it, because I want to ensure the quality of the code we write for Jenkins pipelines), as soon as I started to use it more and more, I noticed that there are some use cases we were are using that were not supported (like using matrix stages in DeclarativePipelines), I added support for it and started to ask Legal to be able to share the code with you 🫠 after 1+ year I'm finally able to do so 🥳
One of the issues that I'm facing is that I added too many changes 🙈 🫠
Let me try to summarize all of those here:
- Use org.jenkins-ci.jpi plugin and classgraph to create mocks for plugins declared in build.gradle with an implementation on how to create stubs/mocks for Steps with default responses and hamcrest matchers
- Support for Mocking imported class
- Support for Matrix stages
- Support for getting coverage reports (using JaCoCo)
NOTE: None of these changes break backward compatibility or require any type of change on the already existing tests.
I try to ask in the jenkins community, but it seems that the maintainers are currently busy, so while analyzing what would be the best way to move forward I started to check the open issues, and I was able to "group" them in the following way:
- Make stubs/mocks """smarter""" Unable to access default/new methods in helper and binding variables is null #47, Testing Shared Libraries that use Jenkins commands #51, Support to withEnv em file .jenkins #52, Feature request: mock global var methods #138, DeclarativePipelineTest - 'docker' is missing the common option for 'reuseNode' #217, No signature of method: com.lesfurets.jenkins.unit.declarative.WhenDeclaration.not() #221, DeclarativePipelineTest - 'when' is missing the option for 'beforeAgent', 'anyOf' and 'allOf' #227, Callstacks should be loaded from classpath #229, Incomplete callStack when using a global var that has method named "error". v1.5 #231, MissingMethodException #234, Scripted pipeline continues executing code after
errorstep is encountered #265, How to assert the agent label of a DeclarativePipelineTest? #277, MissingMethodException calling other groovy file as method #301, thisObject inside pipeline script referes to Declaration class #303, thisObject inside pipeline script referes to Declaration class #303, Mock imported classes #305, withCredentials and usernamePassword Binder no longer works #320, Nested when condition #328, Declarative Pipeline Test skips post steps on exception #338, Provide a way to register an allowed method with arbitrary arguments #345, Unable to test a groovy file that uses a shared library imported in the Jenkins file #356, Unable to test a groovy file that uses a shared library imported in the Jenkins file #356, mocking functions from a shared library #357, Mocking @Field variables with params #361, Add mocking call data to the DockerMock to enable interaction testing. #362, disabling mock for specific sh calls #372, Bound variables are not available inenvironmentclosure #387, Unable to serialize locals UNKNOWN inclass com.lesfurets.jenkins.unit.cps.MockClosure#390, Declarative pipeline: "params" is null inside "environment" block #391, withCredentials does not support ZipFileBinding #392, Docs for how to mock changeset, changelog and other advanced when conditions #393, Unable to call a method from a Script #400, Not able to Mock Another Script #401, Is it possible to modify a script after loading it? #407, How to check the current directory for method calls? #410, How to deal with object references that keep changing in the callstack file #417, runScript incorrectly combines paths #423, Mock scoped properties #435, Can't mock up sh when called from class method #451, Params not accessible in SharedLibrary classes #478, Add support for variables in agent declaration in pipelines #507, Is there a way to assert environment variables exist or get access to the "env" property for assertions? #527, When currentBuild.result change during declarative always closure, it's value not refreshed #550, Can't access 'env' properties in nested bindings #566, How to mock object creation? #589, post-unsuccessful action is not executed for parallel stage when a substage fails #599 - Make JPU behave ""more like Jenkins"" pipelines Shared library classes executed in a different way #159, jdk-11 support #204, Missing "steps" method in scripts under test #93, Add tests to verify interoperability of multiple shared libs #206, Nested stages inside parallel in declarative pipeline not supported #238, Nested when condition #328, Class loading confusion with abstract classes and properties of library-defined types #381, DeclarativePipelineTest should fail if groovy code is not wrapped in a "script" step #384, Enable CPS feature with Declarative Pipelines #403, Variables set in a stage are prematurely applied #434, Can't mock up sh when called from class method #451, Individual "not" conditions seem to have different beahviour than grouping it #545, When currentBuild.result change during declarative always closure, it's value not refreshed #550, post-unsuccessful action is not executed for parallel stage when a substage fails #599, Handling the Jenkins or Hudson property #141, Error when using class Utils from org.jenkinsci.plugins.pipeline.modeldefinition #323, Cannot run inline script when shared library is loaded #472, Docs for how to mock changeset, changelog and other advanced when conditions #393, Is there a way to assert environment variables exist or get access to the "env" property for assertions? #527
- InterceptingGCL issues methodInterceptor closure passed to Script invokeMethod has wrong signature? #59, JenkinsPipelineUnit vs accessing-steps at the base level #104, v1.4 lib class preload causes MissingMethodException with lib var step accepting lib class argument #224, Stack overflow in tests; possible to disable interception for a class? #585, Cannot cast object to an interface type during test #679
- Add Support for code coverage Code coverage of pipeline library - MissingMethodException #46, JenkinsPipelineUnit tests + JaCoCo #103, Modify Loader to enable Cobertura code coverage #119
- Have a way to enable / disable debugging the execution to find problems Write Wiki pages for how-to and troubleshooting #54, Unable to parse Jenkinsfile with Global @Library #161, Wrong binding leads to groovy.lang.MissingMethodException #367, Docs for how to mock changeset, changelog and other advanced when conditions #393
Because some of the changes I made solve some of those issues, I think the best way forward would be to "split" the changes and focus on the biggest list of issues first (Make stubs/mocks """smarter""") and then work the way down that list
This way the PRs will be smaller and focused, what do you think?
Best regards
Gonzalo G.