williamtell
williamtell

Reputation: 301

How to pass Jenkins parameters to Protractor scripts

I would like to pass the following from Jenkins (using a dropdown) to my protractor scripts: enter image description here

browser: Firefox/Chrome/Edge

URL:www.stackoverflow.com or www.duck.com

How can I achieve this?

Will I be able to construct the values in the parameters and send them to the commandline?

EDIT 1 - Adding more information.

I have a set of E2E protractor scripts.

Here's the config file.

config.ts

capabilities: {
        browserName: (process.env.TEST_BROWSER_NAME || 'chrome'),
        version: (process.env.TEST_BROWSER_VERSION || 'ANY'),
        shardTestFiles: true,
        unexpectedAlertBehaviour: 'accept',
        loggingPrefs: {
            performance: 'ALL',
        },

I have process.env.TEST_BROWSER_NAME in the config file. In Jenkins there are options for Chrome and Firefox. What I set in Jenkins should be picked up by the config file and used to execute. This is what I am trying to achieve.

Upvotes: 0

Views: 685

Answers (1)

Sergey Pleshakov
Sergey Pleshakov

Reputation: 8948

Your command will be something like this

#!/bin/bash -xe

protractor protractor.conf.js --baseUrl="${SERVER_URL}" --browser=${TEST_BROWSER_NAME} || error=true

# Fail the build if there was an error
if [ $error ]
then
    exit 1
fi

Let me know if you need further help

Upvotes: 1

Related Questions