Skip to content

Commit

Permalink
feat(doc): Add notes about decalarative pipeline
Browse files Browse the repository at this point in the history
  • Loading branch information
Stanislav Ovchar committed Jan 28, 2020
1 parent 99b8807 commit 7d136ae
Showing 1 changed file with 44 additions and 0 deletions.
44 changes: 44 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ You can mock built-in Jenkins commands, job configurations, see the stacktrace o
# Table of Contents
1. [Usage](#usage)
1. [Configuration](#configuration)
1. [Declarative Pipeline](#declarative-pipeline)
1. [Testing Shared Libraries](#testing-shared-libraries)
1. [Note On CPS](#note-on-cps)
1. [Contributing](#contributing)
Expand Down Expand Up @@ -311,6 +312,49 @@ This will work fine for such a project structure:
└── groovy
└── TestExampleJob.groovy
```
## Declarative Pipeline
There is an experimental support of declarative pipeline.
To try this feature you need to use `DeclarativePipelineTest` calls instead of `BasePipelineTest`

```groovy
// Jenkinsfile
pipeline {
agent none
stages {
stage('Example Build') {
agent { docker 'maven:3-alpine' }
steps {
echo 'Hello, Maven'
sh 'mvn --version'
}
}
stage('Example Test') {
agent { docker 'openjdk:8-jre' }
steps {
echo 'Hello, JDK'
sh 'java -version'
}
}
}
}
```

```groovy
import com.lesfurets.jenkins.unit.declarative
class TestExampleDeclarativeJob extends DeclarativePipelineTest {
@Test
void should_execute_without_errors() throws Exception {
def script = runScript("Jenkinsfile")
assertJobStatusSuccess()
printCallStack()
}
}
```

### DeclarativePipelineTest
It extends `BasePipelineTest` functionality so you can verify your decalrative job the same way
like it was a scripted pipeline

## Testing Shared Libraries

Expand Down

0 comments on commit 7d136ae

Please sign in to comment.