jenkins-pipeline-shared-libraries-gradle-plugin
jenkins-pipeline-shared-libraries-gradle-plugin copied to clipboard
Is it possible to use @NonCPS without the import
When running in Jenkins import com.cloudbees.groovy.cps.NonCPS
is not needed to use @NonCPS
. Is it possible to do this with jenkins-pipeline-shared-libraries-gradle-plugin
? Or maybe I'm missing something?
This happens in Jenkins Groovy because the scripts/libraries get compiled using https://github.com/jenkinsci/workflow-cps-plugin/blob/99e53df804f049521219cb48045ddd861c1682de/src/main/java/org/jenkinsci/plugins/workflow/cps/CpsGroovyShellFactory.java#L102
If you do it right now with this plugin you will get some sort of undefined NonCps
or something during compilation and it will fail. This is probably achievable in the meantime by doing something similar to https://github.com/mkobit/jenkins-pipeline-shared-libraries-gradle-plugin/issues/69
withConfig(configuration) {
imports {
normal('com.cloudbees.groovy.cps.NonCPS')
}
}
It might be more of a pain to bake into this directly into the plugin as some users (like the linked issue) use their own compiler configuration and both Gradle/Groovy do not have an easy way to specify multiple configurations (see GROOVY-8926).