1

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.

1 Answers1

1
  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 ...).

melpomene
  • 84,125
  • 8
  • 85
  • 148
  • 1
    using `cpan Log::Log4perl` command I have installed it but when I am running .pl script or `perl -e 'require Log::Log4perl'` command I am getting the message `Can't locate Log/Log4perl.pm in @INC (@INC contains: /usr/local/lib64/perl5...`. – user5441395 Jul 26 '16 at 13:15
  • I believe, installed location could be the issue here. In log message the installation path shown was `Installing /home/jenkins/perl5/man/man3/Log::Log4perl::Layout.3pm` & whereas while running the script it was looking at `/usr/local/lib64/perl5...` location. If it is so then how could I install to a specific location. Pls correct me if I am wrong. – user5441395 Jul 26 '16 at 13:16
  • @user5441395 That's a [`local::lib`](https://metacpan.org/pod/local::lib) setup, which makes modules install into `~/perl5` and should also make perl load from there. Are you running the `require` command as user `jenkins`? – melpomene Jul 26 '16 at 19:40