Automated testing a jenkins plugin

52 views
Skip to first unread message

Mani Sarkar

unread,
May 18, 2019, 4:00:49 AM5/18/19
to Jenkins Developers
Hi.

I'm looking for pointers to go about testing a Jenkins plugin.

Happy to use mocks but would love to also write a real integration test against a Jenkins server, where the Jenkins server is using the plugin in question and is triggered by the test runner itself.

Has anyone done this before or can point me to some examples that I can examine.

Thanks.

Regards
Mani

Mark Waite

unread,
May 18, 2019, 8:59:46 AM5/18/19
to jenkinsci-dev
On Sat, May 18, 2019 at 2:00 AM Mani Sarkar <sadh...@gmail.com> wrote:
Hi.

I'm looking for pointers to go about testing a Jenkins plugin.


That's great that you want to automate testing of your Jenkins plugin!  First reference should probably be the Jenkins Developers Handbook page called "Testing Jenkins".  More general plugin development topics are covered in the Developer Handbook.  Those more general topics include testing topics and test automation topics.

More information is available in various articles linked from the testing section of a blog post "Plugin Development Tutorials, Videos, and More".

After those overviews, the details in the various testing classes are quite useful as well, including:
If you need a git repository as part of your automated tests, there are test extensions that are used in many locations to simplify automated testing of plugins that need to interact with a git repository.
 
Happy to use mocks but would love to also write a real integration test against a Jenkins server, where the Jenkins server is using the plugin in question and is triggered by the test runner itself.

Has anyone done this before or can point me to some examples that I can examine.

Thanks.

Regards
Mani

--
You received this message because you are subscribed to the Google Groups "Jenkins Developers" group.
To unsubscribe from this group and stop receiving emails from it, send an email to jenkinsci-de...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/jenkinsci-dev/01342628-e77f-423e-ba49-137a5939e1d3%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


--
Thanks!
Mark Waite

Mani Sarkar

unread,
May 18, 2019, 12:29:48 PM5/18/19
to jenkin...@googlegroups.com
Hi Mark 

Thanks for the response. Quite detailed set of resources and yes I would need all of them. Does involve testing against a git repo.  Great to see junit rules are available.

I'll try to share the results once I have completed the work so it will be a good example for others.

Thanks again.

Regards 
Mani

You received this message because you are subscribed to a topic in the Google Groups "Jenkins Developers" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/jenkinsci-dev/m9mtZfrs2tM/unsubscribe.
To unsubscribe from this group and all its topics, send an email to jenkinsci-de...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/jenkinsci-dev/CAO49JtED43carg7dm9TxAe9Pb%3DJX7W0LGtEaE%2BEWbPurHcH4vA%40mail.gmail.com.

For more options, visit https://groups.google.com/d/optout.
--
--
@theNeomatrix369  |  Blog: http://neomatrix369.wordpress.com  | @adoptopenjdk @graalvm @graal @truffleruby  |  Github: http://github.com/neomatrix369  |  Slideshare: https://slideshare.net/neomatrix369 | LinkedIn: https://uk.linkedin.com/in/mani-sarkar

Come to Devoxx UK 2019: http://www.devoxx.co.uk/

Don't chase success, rather aim for "Excellence", and success will come chasing after you!

Mani Sarkar

unread,
May 18, 2019, 12:52:51 PM5/18/19
to jenkin...@googlegroups.com
Hi Mark,

Another question, (I haven't looked into the docs in details), can I create SimplePipeline and MultiPipeline projects just like I can create a FreeStyle project.

I have certain configs to apply to each type of the project - usually the same settings. The crude way would be to copy the config.xml files over but since each run is ephemeral I did like to do it Jenkins-idomatically or programmatically - any tips for this.

Thanks.

Cheers,
Mani
--

Mark Waite

unread,
May 18, 2019, 3:46:44 PM5/18/19
to jenkinsci-dev
On Sat, May 18, 2019 at 10:52 AM Mani Sarkar <sadh...@gmail.com> wrote:
Hi Mark,

Another question, (I haven't looked into the docs in details), can I create SimplePipeline and MultiPipeline projects just like I can create a FreeStyle project.


Pipeline jobs can be created from automated tests.  Refer to the artifact-s3-manager-plugin as one example.
 

For more options, visit https://groups.google.com/d/optout.


--
Thanks!
Mark Waite

Mani Sarkar

unread,
May 22, 2019, 12:19:22 PM5/22/19
to jenkin...@googlegroups.com
Hi Mark, all,

Has anyone implemented the Project and Builder classes to convert project types like

FreeStyleProject
SimplePipeline
MultiPipeline

What would be even better, if I could just load the config.xml files for the above project types via the project/builder classes - is there something close to this?

Regards
Mani


For more options, visit https://groups.google.com/d/optout.


--

Mark Waite

unread,
May 22, 2019, 3:14:46 PM5/22/19
to jenkinsci-dev
On Wed, May 22, 2019 at 10:19 AM Mani Sarkar <sadh...@gmail.com> wrote:
Hi Mark, all,

Has anyone implemented the Project and Builder classes to convert project types like

FreeStyleProject
SimplePipeline
MultiPipeline


I'm not sure I understand your question.  It seems like you're asking for an automated testing library that will convert a project type.  What is the destination for that conversion?  Convert to what?
 
What would be even better, if I could just load the config.xml files for the above project types via the project/builder classes - is there something close to this?


I believe the automated testing functions are written to encourage creation of the job from the program, rather than using configuration files.

However, there is a facility to use static configuration data in a Jenkins test.  Refer to https://jenkins.io/doc/developer/testing/#providing-test-data for more information on that technique.
 

For more options, visit https://groups.google.com/d/optout.


--
Thanks!
Mark Waite

Mani Sarkar

unread,
May 22, 2019, 4:42:35 PM5/22/19
to jenkin...@googlegroups.com
Let me rephrase the question. When I said conversation I meant by hand. Manually written them so to reflect the job description on jenkins itself.

I understand the classes are created so we programmatically rewrite them using the classes provided. However it would help if these building block classes could.load in configuration information at various levels in jenkins ie configuration of plugins or the jobs we run or the jenkinsfile itself. Just helps in writing and changing tests quicker and less translations between the real jenkins system and the test harness.

If there is documentation on any of these I'll be happy to check them out.

Thanks for the link I'll take a look. 


For more options, visit https://groups.google.com/d/optout.

Mark Waite

unread,
May 22, 2019, 5:03:24 PM5/22/19
to jenkinsci-dev
On Wed, May 22, 2019 at 2:42 PM Mani Sarkar <sadh...@gmail.com> wrote:
Let me rephrase the question. When I said conversation I meant by hand. Manually written them so to reflect the job description on jenkins itself.

I understand the classes are created so we programmatically rewrite them using the classes provided. However it would help if these building block classes could.load in configuration information at various levels in jenkins ie configuration of plugins or the jobs we run or the jenkinsfile itself. Just helps in writing and changing tests quicker and less translations between the real jenkins system and the test harness.


Since Jenkins reads those configuration files itself, I'm sure there is a way to cause it to read those files.  Unfortunately, I don't know of any description of that process and have never done that myself.
 

For more options, visit https://groups.google.com/d/optout.


--
Thanks!
Mark Waite

Jesse Glick

unread,
May 29, 2019, 9:25:07 PM5/29/19
to Jenkins Dev
On Wed, May 22, 2019 at 4:42 PM Mani Sarkar <sadh...@gmail.com> wrote:
> I understand the classes are created so we programmatically rewrite them using the classes provided. However it would help if these building block classes could.load in configuration information at various levels in jenkins ie configuration of plugins or the jobs we run or the jenkinsfile itself.

I am not sure I understand the question, but perhaps you are looking
for `@LocalData`?
Reply all
Reply to author
Forward
0 new messages