How to send variables from Jenkins so that the Postman environment can take them?

Currently I have an environment variable called URL, where I add the url that I need to use for each EndPoint that I have, however, I would like to know if it is possible to change this environment variable from Jenkins to indicate another url, for example wanting to work in environments already be it QA, DEV, Production, etc. If this is possible, how can I send that information to my collection (json) of environment variables?

This is my current JenkinsFile

pipeline {
    agent any

    stages {
        stage('Running tests') {
            steps {
                echo 'Testing'
                sh "newman run postman_collection.json -e .postman_environment.json"
            }
        }
    }
}

Hey @dpicado009

Welcome to the Community! :rocket:

You could use either --global-var or --env-var to pass data from Jenkins into the Collection.

If the {{foo}} global variable were used in the Collection, it would resolve it to the bar value.

--global-var "foo=bar"

For your Jenkins example, you would need something like this:

pipeline {
    agent any

    stages {
        stage('Running tests') {
            steps {
                echo 'Testing'
                sh "newman run postman_collection.json -e .postman_environment.json --env-var 'variableName=$JENKINS_VARIABLE'"
            }
        }
    }
}
1 Like

You do not know how much I appreciate it, I could do it, just as you told me…
image

Did that work for you?

It’s hard to tell from the images. :grin:

For what I need yes, is that the images I had to edit because they are names of the work collections and for safety, I put them like this.

1 Like

Hi Team, @danny-dainton,

Could you pls help me – how to pass the ’ Environmental Variables’ and ‘Global Variables’ from Jenkins using postman(newman) – Execute Windows batch command