Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Question: Testing Shared Library definition using JenkinsPipelineUnit #70

Closed
mkobit opened this issue Oct 5, 2017 · 5 comments
Closed

Comments

@mkobit
Copy link

mkobit commented Oct 5, 2017

I (finally) released the first version of https://github.com/mkobit/jenkins-pipeline-shared-libraries-gradle-plugin , which is a Gradle plugin intending to aid in the authoring of shared libraries. I'm sure an additional plugin could be added to support consumers of JenkinsPipelineUnit for build pipeline authors that also want to test their pipeline.

I wrote up an example library at https://github.com/mkobit/jenkins-pipeline-shared-library-example, but was struggling in writing a unit test against the local shared library functionality (at https://github.com/mkobit/jenkins-pipeline-shared-library-example/blob/master/test/unit/groovy/com/mkobit/libraryexample/JPUExampleSpec.groovy right now).

Any suggestions or example to look at for using this as a test harness for Shared Library definition?

@jimcroft
Copy link

Hi @mkobit

I've put a basic skeleton example of what I'm doing here: https://github.com/jimcroft/jenkinslib-example. Hope it helps. If that example does help you load your Jenkins library from a local location (rather than an scm source) could you add a comment to #75?

Thanks

Jim

@baloo42
Copy link

baloo42 commented Oct 28, 2017

Waiting for "local-location" solution too! Meanwhile you can use a copy task in your build.gradle

task initLibraries(type: Copy){
    from('./') {
        include 'src/**/*'
        include 'vars/**/*'
    }
    into 'build/classes/groovy/test/nextlayerci-example@master'
}

test.dependsOn initLibraries

https://github.com/nextlayer-ops/jenkins-pipeline-shared-library-example/blob/master/build.gradle#L12-L20
and
https://github.com/nextlayer-ops/jenkins-pipeline-shared-library-example/blob/master/test/groovy/SayHelloTest.groovy#L18-L30

Btw. If you want to use maven you can use the same trick:
https://github.com/nextlayer-ops/jenkins-pipeline-shared-library-example-maven/blob/master/pom.xml#L54-L80

@mkobit
Copy link
Author

mkobit commented Dec 11, 2017

#75 and #64 are both related to this, would be great to see one of those move forward

@baloo42
Copy link

baloo42 commented Dec 11, 2017

Meanwhile I've found a better solution. Thanks to the SAP guys ;)

https://github.com/SAP/jenkins-library/blob/master/test/groovy/PiperTestBase.groovy#L49-L59

@stchar stchar added doc and removed doc labels Dec 6, 2019
@stchar
Copy link
Contributor

stchar commented Dec 8, 2019

Closing in a favor of #31

@stchar stchar closed this as completed Dec 8, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants