1

我对 Jenkins 和 Perl 很陌生,我正在尝试使用 Jenkins Job 安装 Log4perl 模块。下面是我在 Jenkins 的 Execute shell 框中使用的命令

perl -MCPAN -e 'install Log::Log4Perl'

下面是 Jenkins 控制台日志消息

12:44:49 PATH="/home/jenkins/perl5/bin${PATH:+:${PATH}}"; export PATH;
12:44:49 PERL5LIB="/home/jenkins/perl5/lib/perl5${PERL5LIB:+:${PERL5LIB}}";    export PERL5LIB;
12:44:49  PERL_LOCAL_LIB_ROOT="/home/jenkins/perl5${PERL_LOCAL_LIB_ROOT:+:${PERL_LOCAL_LIB_ROOT}}"; export PERL_LOCAL_LIB_ROOT;
12:44:49 PERL_MB_OPT="--install_base \"/home/jenkins/perl5\""; export PERL_MB_OPT;
12:44:49 PERL_MM_OPT="INSTALL_BASE=/home/jenkins/perl5"; export PERL_MM_OPT;
12:44:49 
12:44:49 Would you like me to append that to /home/jenkins/.bashrc now? [yes] yes
12:44:49 
12:44:49 
12:44:49 commit: wrote '/home/jenkins/.cpan/CPAN/MyConfig.pm'
12:44:49 
12:44:49 You can re-run configuration any time with 'o conf init' in the CPAN shell
12:44:49 Warning: Cannot install Log::Log4Perl, don't know what it is.
12:44:49 Try the command
12:44:49 
12:44:49     i /Log::Log4Perl/
12:44:49 
12:44:49 to find objects with matching identifiers.
12:44:52 [DEV_etl_europcar] $ /bin/sh -xe /tmp/hudson6339194449797505730.sh
12:44:52 Warning: you have no plugins providing access control for builds, so falling back to legacy behavior of permitting any downstream builds to be triggered
12:44:52 DEV_send_welcome_email is disabled. Triggering skipped
12:44:52 Finished: SUCCESS

在日志消息中它说

警告:无法安装 Log::Log4Perl,不知道它是什么。

我不确定我是否应该忽略上述声明。另外如何确认log4perl模块是否安装成功。

4

1 回答 1

1
  1. 您不应该依赖在 Perl 中可以省略字符串的引号。perl -MCPAN -e 'install Log::Log4Perl'最好写成perl -MCPAN -e 'install "Log::Log4Perl"'(如果您尝试安装/更新由 CPAN 本身加载的任何模块,省略引号也会导致奇怪的问题)。

  2. cpan Log::Log4Perl无论如何,整个事情都可以简化。

  3. 发生错误是因为Log::Log4Perl确实不存在,但Log::Log4perl确实存在(小写p)。

因此:cpan Log::Log4perl应该做你想做的事。


至于您的其他问题:“无法安装......”意味着安装失败(这不是您可以忽略的)。

要确认模块是否存在,请尝试加载它:(perl -e 'require Log::Log4perl'如果不存在,您会得到Can't locate Log/Log4perl.pm in @INC ...)。

于 2016-07-22T13:01:31.680 回答