How to run Jenkins Groovy scripts directly from Intellij or Eclipse

Viewed 2386

I have a Groovy repository which contains my Jenkins pipeline's Groovy code.

Currently, I am making changes in an IDE, commiting them to the repository, going to the Jenkins instance, manually triggering a Jenkins job, and checking to see if all of the changes all working. This is taking a lot of time.

Is there a way to do all of this from the IDE itself?

2 Answers

I would suggest to treat your pipeline code like some other code in IT. What are you doing now could be called "manual integration tests" because you are making your code changes and check how that code integrate with other components (like shell commands, jenkins plugins, etc.) on jenkins - this development loop is long and not efficient. So my proposition for you is to write simple unit tests using this framework: https://github.com/jenkinsci/JenkinsPipelineUnit So you can test your pipelines on your machine without any interaction with jenkins.

If you think that it's not proper way for you I would suggest to mix using this plugin for running jobs directly from IntelliJ: https://github.com/programisci/jenkins-control-plugin/ and of course IntelliJ git integration to commit your changes to repository.

Related