Skip to content

Commit d303e49

Browse files
authored
add newman doc (#399)
1 parent 71b66e8 commit d303e49

File tree

2 files changed

+107
-0
lines changed

2 files changed

+107
-0
lines changed
+70
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,70 @@
1+
# newmanExecute
2+
3+
## Description
4+
5+
This script executes your [Postman](https://www.getpostman.com) tests from a collection via the [Newman](https://www.getpostman.com/docs/v6/postman/collection_runs/command_line_integration_with_newman) command line collection.
6+
7+
## Prequisites
8+
9+
- prepared Postman with a test collection
10+
11+
## Example
12+
13+
Pipeline step:
14+
15+
```groovy
16+
newmanExecute script: this
17+
```
18+
19+
This step should be used in combination with `publishTestResults`:
20+
21+
```groovy
22+
newmanExecute script: this, failOnError: false
23+
publishTestResults script: this, junit: [pattern: '**/newman/TEST-newman.xml']
24+
```
25+
26+
## Parameters
27+
28+
| name | mandatory | default | possible values |
29+
|------|-----------|---------|-----------------|
30+
| `dockerImage` | no | | |
31+
| `failOnError` | no | | `true`, `false` |
32+
| `gitBranch` | no | | |
33+
| `gitSshKeyCredentialsId` | no | | |
34+
| `newmanCollection` | no | | |
35+
| `newmanEnvironment` | no | | |
36+
| `newmanGlobals` | no | | |
37+
| `newmanRunCommand` | no | | |
38+
| `script` | yes | | |
39+
| `stashContent` | no | | |
40+
| `testRepository` | no | | |
41+
42+
- `dockerImage` - Docker image for code execution.
43+
- `failOnError` - Defines the behavior, in case tests fail.
44+
- `gitBranch` - see `testRepository`
45+
- `gitSshKeyCredentialsId` - see `testRepository`
46+
- `newmanCollection` - The test collection that should be executed. This could also be a file pattern.
47+
- `newmanEnvironment` - Specify an environment file path or URL. Environments provide a set of variables that one can use within collections. see also [Newman docs](https://github.com/postmanlabs/newman#newman-run-collection-file-source-options)
48+
- `newmanGlobals` - Specify the file path or URL for global variables. Global variables are similar to environment variables but have a lower precedence and can be overridden by environment variables having the same name. see also [Newman docs](https://github.com/postmanlabs/newman#newman-run-collection-file-source-options)
49+
- `newmanRunCommand` - The newman command that will be executed inside the docker container.
50+
- `script` - The common script environment of the Jenkinsfile running. Typically the reference to the script calling the pipeline step is provided with the this parameter, as in script: this. This allows the function to access the commonPipelineEnvironment for retrieving, for example, configuration parameters.
51+
- `stashContent` - If specific stashes should be considered for the tests, you can pass this via this parameter.
52+
- `testRepository` - In case the test implementation is stored in a different repository than the code itself, you can define the repository containing the tests using parameter `testRepository` and if required `gitBranch` (for a different branch than master) and `gitSshKeyCredentialsId` (for protected repositories). For protected repositories the `testRepository` needs to contain the ssh git url.
53+
54+
## Step configuration
55+
56+
We recommend to define values of step parameters via [config.yml file](../configuration.md).
57+
58+
In following sections the configuration is possible:| parameter | general | step | stage |
59+
|-----------|---------|------|-------|
60+
| `dockerImage` |  | X | X |
61+
| `failOnError` |  | X | X |
62+
| `gitBranch` |  | X | X |
63+
| `gitSshKeyCredentialsId` |  | X | X |
64+
| `newmanCollection` |  | X | X |
65+
| `newmanEnvironment` |  | X | X |
66+
| `newmanGlobals` |  | X | X |
67+
| `newmanRunCommand` |  | X | X |
68+
| `script` || X | X |
69+
| `stashContent` |  | X | X |
70+
| `testRepository` |  | X | X |

vars/newmanExecute.groovy

+37
Original file line numberDiff line numberDiff line change
@@ -11,16 +11,53 @@ import groovy.transform.Field
1111
@Field Set GENERAL_CONFIG_KEYS = STEP_CONFIG_KEYS
1212

1313
@Field Set STEP_CONFIG_KEYS = [
14+
/**
15+
* Docker image for code execution.
16+
*/
1417
'dockerImage',
18+
/**
19+
* Defines the behavior, in case tests fail.
20+
* @possibleValues `true`, `false`
21+
*/
1522
'failOnError',
23+
/**
24+
* see `testRepository`
25+
*/
1626
'gitBranch',
27+
/**
28+
* see `testRepository`
29+
*/
1730
'gitSshKeyCredentialsId',
31+
/**
32+
* The test collection that should be executed. This could also be a file pattern.
33+
*/
1834
'newmanCollection',
35+
/**
36+
* Specify an environment file path or URL. Environments provide a set of variables that one can use within collections.
37+
* see also [Newman docs](https://github.com/postmanlabs/newman#newman-run-collection-file-source-options)
38+
*/
1939
'newmanEnvironment',
40+
/**
41+
* Specify the file path or URL for global variables. Global variables are similar to environment variables but have a lower precedence and can be overridden by environment variables having the same name.
42+
* see also [Newman docs](https://github.com/postmanlabs/newman#newman-run-collection-file-source-options)
43+
*/
2044
'newmanGlobals',
45+
/**
46+
* The shell command that will be executed inside the docker container to install Newman.
47+
*/
2148
'newmanInstallCommand',
49+
/**
50+
* The newman command that will be executed inside the docker container.
51+
*/
2252
'newmanRunCommand',
53+
/**
54+
* If specific stashes should be considered for the tests, you can pass this via this parameter.
55+
*/
2356
'stashContent',
57+
/**
58+
* In case the test implementation is stored in a different repository than the code itself, you can define the repository containing the tests using parameter `testRepository` and if required `gitBranch` (for a different branch than master) and `gitSshKeyCredentialsId` (for protected repositories).
59+
* For protected repositories the `testRepository` needs to contain the ssh git url.
60+
*/
2461
'testRepository'
2562
]
2663

0 commit comments

Comments
 (0)