Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Develop groovy scripts for jenkins in vscode or intellij

Is it possible to connect to jenkins instance to get the available libraries (including the ones from plugins) for locally developing groovy scripts with code completion in intellij or vscode?

like image 523
Balajee Ks Avatar asked Oct 15 '25 16:10

Balajee Ks


1 Answers

It is not possible to have the same library as that of Jenkins instance to compile groovy inside these IDE'S. Instead you need to have Groovy SDK installed and configured for each of there IDEs separately. (IntelliJ is simple to configure while VS Code usages .json file for all configuration). Once you have the Groovy SDK lib configured, within IDE project you can compile and run the sample .groovy (And or .gdsl) script (without any jenkins plugin). If you are trying to trigger .jenkinsfile then, you need to change configuration in IDE to treat .jenkinsfile equal to .groovy file see below screenshot. enter image description here

While it is possible to configure your Jenkins instance into IDE and also to control (Run, cancel and re-run) the jobs directly remotely in runtime from IntelliJ or from VS Code. For this you can use;

  1. Jenkins-Control-Plugin - IntelliJ IDEA

    • To Configure Jenkins instance is very simple. see the Link here
  2. Jenkins Jack(many other plugins are available but this is most popular) - VS Code.

    • I Struggled a bit to configure the Jenkins Jack but with this you can compile the Groovy and trigger it remotely. see the link JenkinsJack
  3. Jenkins Runner - VS Code

    • This is same as that of Jenkins Control Plugin mentioned in point 1.

My favorite is VS code with Jenkins Jack simple and effective.

like image 126
np2807 Avatar answered Oct 18 '25 12:10

np2807