Search code examples
perljenkinslog4perl

How to install Log4perl module using Jenkins


I am very new to Jenkins and Perl and I am trying to install Log4perl module using Jenkin Job. Below is the command which I have used in Jenkin's Execute shell box

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

And below is the Jenkin console log message

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

In log message it says

Warning: Cannot install Log::Log4Perl, don't know what it is.

I am not sure whether I should ignore the above statement or not. Also How can confirm whether the log4perl module is installed successfully or not.


Solution

    1. You shouldn't rely on being able to omit quotes around strings in Perl. perl -MCPAN -e 'install Log::Log4Perl' is better written as perl -MCPAN -e 'install "Log::Log4Perl"' (omitting the quotes also causes bizarre problems if you try to install/update any module loaded by CPAN itself).

    2. The whole thing can be simplified to cpan Log::Log4Perl anyway.

    3. The error occurs because Log::Log4Perl really doesn't exist, but Log::Log4perl does (lowercase p).

    Thus: cpan Log::Log4perl should do what you want.


    As for your other questions: "Cannot install ..." means the installation failed (that's not something you can just ignore).

    To confirm whether the module is there, try to load it: perl -e 'require Log::Log4perl' (if it's not there, you'll get Can't locate Log/Log4perl.pm in @INC ...).