Description
This article discusses how to expand the CloudBees CD (CloudBees Flow) Perl distribution by adding Perl modules, say from CPAN or third-party vendors.
Solution
Install Perl modules using the CPAN installer. The installer comes with the CloudBees CD (CloudBees Flow) Perl distribution in /perl/bin.
On Linux
From the command line use:
/perl/bin/perl -MCPAN -e 'install'
On Windows
-
To be compatible with CloudBees CD (CloudBees Flow):
-
CloudBees CD (CloudBees Flow) 6.x distributions use Perl 5.8 for ec-perl
-
If the Perl package is not Perl only and requires compiling for say C code:
-
Use Windows Visual Studio VC6. This is what CloudBees CD (CloudBees Flow) uses and you want to use the same version.
-
Make sure that cl and nmake are both on your path. The Windows Visual Studio install comes with a Command Prompt that has these executables already in the path.
-
-
-
There are additional steps on Windows because there is a problem with Perl and CPAN when running from a directory with spaces in the name. By default, CloudBees CD (CloudBees Flow) has spaces in the install directory.
-
Use a network drive to eliminate other references to spaces in the path.
-
Use subst to mount the Perl directory under a different drive letter:
c:\> subst x: "c:\program files\electric cloud\electriccommander"
-
Temporarily add X:\perl\bin to your Windows path.
-
-
Change the \perl\lib\config.pm file to eliminate spaces in references to the CloudBees CD (CloudBees Flow) path. For example:
#archlibexp => 'C:\Program Files\Electric Cloud\ElectricCommander\perl\lib', archlibexp => 'X:\perl\lib', #privlibexp => 'C:\Program Files\Electric Cloud\ElectricCommander\perl\lib', privlibexp => 'X:\perl\lib', #scriptdir => 'C:\Program Files\Electric Cloud\ElectricCommander\perl\lib', scriptdir => 'X:\perl\lib', #sitearchexp => 'C:\Program Files\Electric Cloud\ElectricCommander\perl\site\lib', sitearchexp => 'X:\perl\site\lib', #sitelibexp => 'C:\Program Files\Electric Cloud\ElectricCommander\perl\site\lib', sitelibexp => 'X:\perl\site\lib',
-
Use the CPAN installer to complete the module install.
-
Start CPAN from the new location:
-
c:\> x:\perl\bin\perl -MCPAN -e shell
-
Configure CPAN to install in the new location:
-
cpan> o conf makepl_arg PREFIX=x:/perl
-
Install the module
cpan> install ---- <br /> * Ending CPAN ---- cpan> quit ---- #### CloudBees CD (CloudBees Flow) upgrade During a CloudBees CD (CloudBees Flow) upgrade, the installer makes every attempt to preserve Perl packages. In the future, however, the version of Perl may change, which may entail the reinstall of the added Perl packages. #### Other sources of help Here are some descriptions on how to install CPAN modules: 1. <https://perl.about.com/od/packagesmodules/qt/perlcpan.htm> 2. <https://search.cpan.org/src/CMUNGALL/go-perl-0.08/INSTALL.html> (a specific module install example) ## Alternative Plugin Approach for CloudBees CD (CloudBees Flow)-specific Perl Modules Another approach is to leverage the plugin technology by adding a subdirectory to the plugin hierarchy to house the Perl module. Assume you have a plugin named cmdrUtils that has a src/lib directory containing two perl modules (ecUtils.pm and dbgUtils.pm). Reference these modules from CloudBees CD (CloudBees Flow) steps or command line scripts as follows: From steps: ---- use lib "$ENV{'COMMANDER_PLUGINS'}/$[/plugins/dfUtils]/lib"; use dbgUtils; use ecUtils; ---- From command line scripts (after setting the appropriate ECPERLLIB env var in the startup scripts): ---- use lib "$ENV{'ECPERLLIB'}"; use dbgUtils; use ecUtils;
This way, the Perl modules' versions are manageable and access to the CloudBees CD (CloudBees Flow) server installation hierarchy is not necessary, only a login that can install plugins.