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

Is it possible to use @NonCPS without the import #79

Open
externl opened this issue Dec 13, 2018 · 1 comment
Open

Is it possible to use @NonCPS without the import #79

externl opened this issue Dec 13, 2018 · 1 comment

Comments

@externl
Copy link

externl commented Dec 13, 2018

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?

@mkobit
Copy link
Owner

mkobit commented Dec 13, 2018

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 #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).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants