如何使用Jenkins安装Log4perl模块

时间:2016-07-22 12:54:56

标签: perl jenkins log4perl

我是Jenkins和Perl的新手,我正在尝试使用Jenkin Job安装Log4perl模块。下面是我在Jenkin的执行shell框中使用的命令

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

以下是Jenkin控制台日志消息

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模块是否已成功安装。

1 个答案:

答案 0 :(得分: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)。

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

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

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