F5 Programmability Training > Class 2: Building Continuous Delivery Pipelines > Module 2: F5 f5-postman-workflows & f5-newman-wrapper Source | Edit on
Lab 2.3: f5-newman-wrapper Introduction¶
As shown in the previous lab, we can manually execute collections and folders using the Postman GUI to achieve end results on BIG-IP devices. While this capability is important in a test/prototyping phase, we need to ensure we can execute these manual steps as an automated process.
To achieve this goal we can use the f5-newman-wrapper tool. This tool allows a user to specify a workflow in a JSON formatted file, this includes Input Variables, the collections and folders, and executes various output options to provide feedback and run details in a programmatic fashion.
The core element of a workflow that can be executed by f5-newman-wrapper is a
JSON formatted input file. In this lab we will introduce the file format.
Task 1 - Explore the workflow JSON format¶
To introduce the format of the workflow file we will use an example that recreates the simple workflow we executed manually in the previous lab. We will explore the file in sections followed by showing the whole file.
Define Name and Description¶
1 2 3 4 | {
"name":"Wrapper_Demo_1",
"description":"Execute a chained workflow that authenticates to a BIG-IP and retrieves it's software version"
}
|
Define Global Settings for the Run¶
This section defines how f5-newman-wrapper will run this workflow. The attributes are explained in the table below.
1 2 3 4 5 6 7 8 9 10 | {
"globalEnvVars":"../framework/f5-postman-workflows.postman_globals.json",
"globalOptions": {
"insecure":true,
"reporters":["cli"]
},
"saveEnvVars":true,
"outputFile":"Wrapper_Demo_1-run.json",
"envOutputFile":"Wrapper_Demo_1-env.json"
}
|
| Attribute | Description |
|---|---|
globalEnvVars |
This is the file that contains the Global environment variables used by Newman. This file is generated by the f5-postman-workflows build scripts and contains the same global variables as we saw in the previous lab that installed the framework into the Postman GUI client |
globalOptions |
Specify the global options for newman. Available options are documented at: https://github.com/postmanlabs/newman#api-reference Note Removing the |
saveEnvVars |
Save the environment variables at the end of the run to a file |
outputFile |
The file to save the run details to. |
envOutputFile |
The file to save the environment variables at the end of the run to. |
Define Input Variables¶
This section specifies the Input Variables for the workflow. The name
globalVars conveys that the variables defined here will be present for
each request in the defined workflow (the global scope from a workflow
perspective). Variables can also be defined within each item in a workflow
(the local scope from a item perspective). In the case of a global and local
variable that is named identically, the local scope variable will take
precedence.
1 2 3 4 5 6 7 | {
"globalVars": {
"bigip_mgmt": "10.1.1.10",
"bigip_username":"admin",
"bigip_password":"admin"
}
}
|
Define the Workflow Collections and Ordering¶
This section defines the workflow and collections and folders that it is
comprised of. The workflow attribute is an ordered array that contains
objects defining each collection and folder to run.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 | {
"workflow": [
{
"name":"Authenticate to BIG-IP",
"options": {
"collection":".. /collections/BIG_IP/BIGIP_API_Authentication.postman_collection.json",
"folder":"1_Authenticate"
}
},
{
"name":"Get BIG-IP Software Version",
"options": {
"collection":"../collections/BIG_IP/BIGIP_Operational_Workflows.postman_collection.json",
"folder":"4A_Get_BIGIP_Version"
}
}
]
}
|
Lets look at the item in the workflow that performs authentication:
1 2 3 4 5 6 7 | {
"name":"Authenticate to BIG-IP",
"options": {
"collection":".. /collections/BIG_IP/BIGIP_API_Authentication.postman_collection.json",
"folder":"1_Authenticate"
}
}
|
The name attribute specifies the name for this item. The options
object specifies the parameters used to execute this particular item. In our
case the collection attribute refers to the file containing the
BIGIP_API_Authentication collection. The folder attribute specifies
the name of the folder to run in the collection.
By default all output variables from a collection or folder are passed to the next item in the workflow. This allows us to chain collections together as needed to build workflows.
Final Workflow JSON¶
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 | {
"name":"Wrapper_Demo_1",
"description":"Execute a chained workflow that authenticates to a BIG-IP and retrieves it's software version",
"globalEnvVars":"../framework/f5-postman-workflows.postman_globals.json",
"globalOptions": {
"insecure":true,
"reporters":["cli"]
},
"globalVars": {
"bigip_mgmt": "10.1.1.10",
"bigip_username":"admin",
"bigip_password":"admin"
},
"saveEnvVars":true,
"outputFile":"Wrapper_Demo_1-run.json",
"envOutputFile":"Wrapper_Demo_1-env.json",
"workflow": [
{
"name":"Authenticate to BIG-IP",
"options": {
"collection":".. /collections/BIG_IP/BIGIP_API_Authentication. postman_collection.json",
"folder":"1_Authenticate"
}
},
{
"name":"Get BIG-IP Software Version",
"skip":false,
"options": {
"collection":".. /collections/BIG_IP/BIGIP_Operational_Workflows. postman_collection.json",
"folder":"4A_Get_BIGIP_Version"
}
}
]
}
|