|
| 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 | X | |
| 69 | +| `stashContent` | | X | X | |
| 70 | +| `testRepository` | | X | X | |
0 commit comments