I have a postman collection which I have managed to run from Jenkins using Newman.
I have a groovy pipeline in which I install the dependencies included in my package.json (Newman in this case). From here, I can run a shell script to call the collection:
stage( 'DEV: Install Dependencies' ) {
sh 'npm install -g newman'
sh 'npm install'
}
stage( 'Running API Tests') {
sh 'bash ./scripts_uat/create-new-product.sh'
}
create-new-product.sh calls the parameterized create-new-product.json which uses a number of global vars held in a file global-vars.json, a snippet of which below:
//create-new-product.json
....
"body": {
"mode": "raw",
"raw": "{\n \"dept\": \"{{department}}\",\n \"prodId\": \".
{{productId}}\",\n...
I am unclear how I can expose the global vars within Jenkins such that they can be passed as Choice Params from within Jenkins.
A snippet of the global-vars.json:
{
"_": {
"postman_variable_scope": "globals",
"postman_exported_at": "2020-02-27T14:37:33.884Z",
"postman_exported_using": "Newman/4.5.7"
},
"id": "3147c1d3-e108-4689-ad7b-0cc719647103",
"name": "globals",
"values": [
{
"type": "any",
"value": "8293004039",
"key": "product_id"
},// more vars
How would I expose {{productID}} such that it can override the value within global-vars.json?
Can anyone give me some pointers? There is probably a better way of doing this.