-1

Background

I am running a Jenkns Job, called Job A, that feeds its build parameters into a perl script, called ScriptA.pl, in the following format below:

#Check the input params
my $PARAM1 = $ENV{ "PARAM1" };
my $PARAM2 = $ENV{ "PARAM2" };
.....more params fed in the same way
if ( $PARAM1 eq "" ) {
    print "PARAM1 is a required parameter.\n";
    exit 1;
}
if ( $PARAM2 eq "" ) {
    print "PARAM2 is a required parameter.\n";
    exit 1;
}
.....more param checks done in the same way
###Script then runs a bunch of execution statements####

Problem

I am trying to run this script from Linux command line in cshell in the following way to test that the execution component works:

/% ScriptA.pl jetFuel steelBeams

And it thinks that no parameters have been entered, since this error is returned

PARAM1 is a required parameter.

Question

How do I properly input Jenkins parameters into a Jenkins script from command line?

isakbob
  • 1,439
  • 2
  • 17
  • 39

1 Answers1

1

If you can't modify the Perl script so it reads command-line parameters (which would improve its general usability to boot), maybe create a simple wrapper script:

#/bin/sh
env PARAM1="$1" PARAM2="$2" perl ScriptA.pl

(Yes, sh. Nobody should use csh for anything in 2019.)

tripleee
  • 175,061
  • 34
  • 275
  • 318
  • I know [csh sucks](https://www-uxsup.csx.cam.ac.uk/misc/csh.html) believe me I have asked this at work as to why we won't use bash as the default. But I don't have an option in this case since the company default is cshell. – isakbob Mar 12 '19 at 19:26