如何从命令行将参数输入到 Jenkins perl 脚本中?

How do I input paramters into a Jenkins perl script from command line?

背景

我正在 运行创建一个名为 Job A 的 Jenkns 作业,它将其构建参数输入到一个名为 ScriptA.pl 的 perl 脚本中,格式如下:

#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####

问题

我正尝试通过以下方式从 cshell 中的 Linux 命令行 运行 此脚本,以测试执行组件是否正常工作:

/% ScriptA.pl jetFuel steelBeams

而且认为没有输入参数,所以返回这个错误

PARAM1 is a required parameter.

问题

如何从命令行将 Jenkins 参数正确输入到 Jenkins 脚本中?

如果您不能修改 Perl 脚本以便它读取命令行参数(这将提高其启动的一般可用性),也许可以创建一个简单的包装脚本:

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

(是的,sh。2019 年任何人都不应该使用 csh。)