NewWorld
NewWorld

Reputation: 764

Multiple value parameter in jenkins

I have a situation where i need to use multiple value parameter or using extended-choice-parameter for Jenkins where we can select multiple options for my parameter. I have different protractor test suites {Suite1, Suite2, Suite3, Suite4} which i am using as parameter of build for user to select which suite they want to execute. If they select multiple suite in option, how should i read those values in my shell script? Currently i am using $Suite to read value but i am not sure what should i use to read multiple values selected. Can someone please help?

Upvotes: 0

Views: 833

Answers (1)

chenchuk
chenchuk

Reputation: 5742

One option is:

  1. get input of simple params (S1, S2)
  2. build the string using 'execute shell'
  3. save it to file in the workspace
  4. inject it with the EnvInject plugin

execute-shell block:

#!/bin/sh
SUITS="{"
if [ "${S1}" = "test-1" ]; then
  SUITS="${SUITS}test-1 "
fi
if [ "${S2}" = "test-2" ]; then
  SUITS="${SUITS}test-2 "
fi
SUITS="${SUITS}}"
# SUITS="{test-1 test2- }"
cat "SUITS=${SUITS}" > suits.file

Then inject the file using the EnvInject plugin and SUITS will be available in the workspace

Upvotes: 1

Related Questions