0

The command I'm using in Jenkins execute the shell build step:

./tibemsadmin -server servername:portno -user admin -password pass -script sample.sh

My Requirement:

How do I pass a parameter to the above sample.sh which is already used to execute a set of commands via tibemsadmin

Example for my requirement:

./tibemsadmin -server servername:portno -user admin -password pass -script sample.sh arg1 arg2 arg 3

If I am passing arg1 arg2 and arg3 like above and build the project Jenkins console output shows Invalid command line parameter

The above parameters like arg1 arg2 and arg3 are Jenkins build parameters

For example if test is a Jenkins build parameter then I want to pass the parameter to sample.sh file as:-

./tibemsadmin -server servername:portno -user admin -password pass -script sample.sh $test

tibemsadmin is a .bat file I think

So my exact requirement is how to pass any number of Jenkins build parameters(ex:$test1 $ver $server) to a shell script file(sample.sh) as:

./tibemsadmin -server servername:portno -user admin -password pass -script sample.sh $test $ver $server

So is there any possibility or way to pass any number of Jenkins parameters to sample.sh file similar to my above example.

Thanks in advance.

Tancho
  • 1,581
  • 3
  • 22
  • 40

1 Answers1

0

Suppose I have a sample.sh file:
sample.sh
echo $1 echo $2

Jenkins job with build parameters as arg1 and arg2

In Job configure, execute shell command sh ${WORKSPACE}/sample.sh ${arg1} ${arg2}

When I run the Jenkins job by passing arg1 and arg2 actual values, then I can see the arg1 and arg2 values which I have passed printed in console log.

psalvi21
  • 143
  • 5
  • In my case i have to pass jenkins parameters to a shell script file that has been passed as a script using -script to to execute a set of ems commands. For ex: ./tibemsadmin -server servername:portno -user admin -password pass -script sample.sh ${test} ${ver} ${server} But when i pass jenkins parameter to the above sample.sh jenkins console output shows Invalid command line parameter So i want to know how to pass jenkins parameter as an argument *in this line of code* ./tibemsadmin -server servername:portno -user admin -password pass -script sample.sh *in this place* – Ravi Shankar Jul 12 '17 at 12:22