Unit tests for Scripted Pipeline

29 views
Skip to first unread message

Sverre Moe

unread,
Apr 7, 2019, 4:10:07 PM4/7/19
to Jenkins Users
Is it possible to create unit tests for our scripted pipeline?

How can certain sections of the pipeline be mocked, like fetching from Git, tagging to Git, Uploading to Nexus?

Anyone been able to fully unit test scripted pipeline?

I found this project at GitHub regarding Unit testing pipelines.


Jan Monterrubio

unread,
Apr 7, 2019, 6:16:46 PM4/7/19
to jenkins...@googlegroups.com
We've used this fork too  https://github.com/macg33zr/pipelineUnit to unit test the declarative pipelines

Virus-free. www.avg.com

--
You received this message because you are subscribed to the Google Groups "Jenkins Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to jenkinsci-use...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/jenkinsci-users/bfb4737c-8813-40ef-be39-193d905cd1b8%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Aaron Digulla

unread,
Apr 11, 2019, 5:52:04 AM4/11/19
to Jenkins Users
I'm using this right now and it works well. Out of the box, several commands are not mocked (build, withMaven, etc) but it's simple to do so (usually just one line).

withMaven() is a bit more complex to write to make sure the bindings are correct. See https://github.com/jenkinsci/JenkinsPipelineUnit/issues/140

Regards,

-- 
Aaron Digulla
 
Reply all
Reply to author
Forward
0 new messages