How to import Jenkins plugins to Groovyscript?
I am trying to find some simple examples of how to use Jenkins git client plugin without much luck. I am not importing the git-client-plugin correctly when I run the groovy script execution (using the groovy plugin).
import org.jenkinsci.plugins.gitclient;
import hudson.EnvVars;
import hudson.util.StreamTaskListener;
StreamTaskListener stl = new StreamTaskListener();
EnvVars env = new EnvVars();
GitClient git = Git.with(stl, env)
.in('tbd')
.getClient();
This is the error I am getting when I run groovy script. Classes in hudson are imported fine.
startup failed:
Script1.groovy: 1: unable to resolve class org.jenkinsci.plugins.gitclient
@ line 1, column 1.
import org.jenkinsci.plugins.gitclient;
^
What changes do I need to make to import the git client?
+3
source to share
1 answer
As mentioned in the comments, you want a more general import.
Gitclient is a package, if you want to import all the classes in this package you must add:
import org.jenkinsci.plugins.gitclient.*;
Or just the two classes you are using:
import org.jenkinsci.plugins.gitclient.Git;
import org.jenkinsci.plugins.gitclient.GitClient;
HTH
+2
source to share