-
Notifications
You must be signed in to change notification settings - Fork 97
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
Improve unit test framework to execute in near sandboxed jenkins environment #32
Comments
Ok, the thing is moving slightly - right now I'm going through mocking of CPS Script, hopefully this is possible. |
Prepared CPS test base #49 and posted a couple of issues to JenkinsPipelineUnit:
Still not used security plugin I think, but CPS is already something. |
JenkinsPipelineUnit don't allow to execute CPS tests on somehow complex pipelines that using groovy closures methods (.find/.findAll and many others) due to issue (for example [1,2,3].findAll { it > 1 } will return false instead of [2,3]), like the one was fixed here: jenkinsci/workflow-cps-plugin#124 |
I tried a number of ways and seems just one is working well for us: Running CPS tes base of the JenkinsPipelineUnitUses groovy-cps, but without improvements of workflow-cps plugin, so making not much sense. Running JenkinsRule with intercepting CpsScriptUnfortunately will not work properly, because CpsScript is highly protected: Running JenkinsRule with intercepting groovy-cps Invoker classes (SandboxInvoker, DefaultInvoker)Working well with minimal changes and there is a minimal risk of some additional changes. Also allow to prepare rules for sandboxed or non-sandboxed scopes and choose the depth of the intercepting:
So the last approach looks promising. |
Just completed JenkinsRule unit tests implementation, there is still some issues - but looks like it's working as expected. |
Asked here to help with some jenkins-related issues here: https://issues.jenkins-ci.org/browse/JENKINS-33925 |
The issue with not proper placing of the |
Ok, found workaround - just use the current node (if it's |
Davin suggested a couple of other ways to achieve the same result to register the custom interceptor here: cloudbees/groovy-cps#107 (comment) |
Right now unit tests are executing in a quite relaxed environment, but we need a way to check that the same logic will work in jenkins sandbox (by using the original script-security plugin) and right now it's hard to say for sure.
The text was updated successfully, but these errors were encountered: