forked from macg33zr/pipelineUnit
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
1 changed file
with
45 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,49 @@ | ||
# pipelineUnit | ||
|
||
This project demonstrates how to write unit tests for Jenkins pipeline code including declarative pipelines, scripted pipelines and shared library code under the /vars area. The framework does not strictly validate the pipeline syntax but it will emulate the pipeline using the JenkinsPipelineUnit framework and can validate any groovy sript sections in the pipeline and logic. It may not be complete for all pipeline syntax. | ||
This project demonstrates how to write unit tests for Jenkins pipeline code including declarative pipelines, scripted pipelines and shared library code under the /vars area. The framework does not strictly validate the pipeline syntax but it will emulate the pipeline using the JenkinsPipelineUnit framework and can validate any groovy script sections in the pipeline and logic. It may not be complete for all pipeline syntax. | ||
|
||
It is using Spock, Gradle and Groovy and the JenkinsPipelineUnit framework available here: https://github.com/lesfurets/JenkinsPipelineUnit | ||
|
||
The unit test is actually testing the Jenkinsfile that builds this Gradle project on Jenkins. | ||
|
||
Here is what some exampled output looks like from one of the Jenkinsfile pipeline spock tests: | ||
|
||
post failure skipped as not FAILURE | ||
post unstable skipped as SUCCESS | ||
>>>>>> pipeline call stack ------------------------------------------------- | ||
Jenkinsfile.run() | ||
Jenkinsfile.pipeline(groovy.lang.Closure) | ||
Jenkinsfile.agent(groovy.lang.Closure) | ||
Jenkinsfile.options(groovy.lang.Closure) | ||
Jenkinsfile.logRotator({numToKeepStr=10}) | ||
Jenkinsfile.buildDiscarder(null) | ||
Jenkinsfile.timestamps() | ||
Jenkinsfile.triggers(groovy.lang.Closure) | ||
Jenkinsfile.pollSCM(*/5 * * * *) | ||
Jenkinsfile.stages(groovy.lang.Closure) | ||
Jenkinsfile.stage(Checkout, groovy.lang.Closure) | ||
Jenkinsfile.steps(groovy.lang.Closure) | ||
Jenkinsfile.deleteDir() | ||
Jenkinsfile.checkout(groovy.lang.Closure) | ||
Jenkinsfile.stage(build, groovy.lang.Closure) | ||
Jenkinsfile.steps(groovy.lang.Closure) | ||
Jenkinsfile.tool({name=GRADLE_3, type=hudson.plugins.gradle.GradleInstallation}) | ||
Jenkinsfile.withEnv([GRADLE_HOME=GRADLE_3_HOME], groovy.lang.Closure) | ||
Jenkinsfile.withEnv([PATH=/some/path:GRADLE_3_HOME/bin], groovy.lang.Closure) | ||
Jenkinsfile.echo(GRADLE_HOME=GRADLE_3_HOME) | ||
Jenkinsfile.echo(PATH=/some/path:GRADLE_3_HOME/bin) | ||
Jenkinsfile.sh(gradle clean build test -i) | ||
Jenkinsfile.stage(validate, groovy.lang.Closure) | ||
Jenkinsfile.steps(groovy.lang.Closure) | ||
Jenkinsfile.echo(TODO: syntactic validation of Jenkinsfiles) | ||
Jenkinsfile.post(groovy.lang.Closure) | ||
Jenkinsfile.always(groovy.lang.Closure) | ||
Jenkinsfile.echo(pipeline unit tests completed) | ||
Jenkinsfile.success(groovy.lang.Closure) | ||
Jenkinsfile.echo(pipeline unit tests PASSED) | ||
Jenkinsfile.failure(groovy.lang.Closure) | ||
Jenkinsfile.changed(groovy.lang.Closure) | ||
Jenkinsfile.echo(pipeline unit tests results have CHANGED) | ||
Jenkinsfile.unstable(groovy.lang.Closure) | ||
Jenkinsfile.execute() | ||
|