Sunday, February 4, 2024

CI/CD Pipeline for SFCC - Jenkins - part II

On a previous post, we went over setting up a CI/CD pipeline for SFCC using Windows.

What's next?

Let's give it a try with Linux!!!

Why Linux and not Windows?

Linux is much more efficient in terms of managing and executing resource intensive tasks like compiling and packaging code projects. 

Historically, Linux is 30-40% faster when performing such tasks, a few additional elements to consider:
  • Linux performs faster git operations - Linux performs command line git operations faster than Windows (as evidenced by ci.jenkins.io git client plugin automated tests requiring 12 minutes on Linux and 22 minutes on Windows)
  • Fewer locking issues - Linux file system locking semantics are more forgiving than Windows file system locking semantics. It is more likely that a "busy file" on Windows will disrupt the Jenkins controller than it will on Linux.
  • License cost. 

Our journey has taken us from a process that used to take 3-4 hours when we were leveraging a vendor owned and managed implementation to this:

So expect at least to achieve better times than with Windows.

If you are still with me, this is the translation into shell:

Code build

#!/bin/bash
export PATH=/usr/local/bin/7zip:$PATH
export PREFIX="B2C"
export COMMIT_SHORT="${GIT_COMMIT::7}"
export BRANCH=${GIT_BRANCH//\//_}
export BUILD_VERSION=${PREFIX}_${BRANCH}_${BUILD_NUMBER}_${COMMIT_SHORT}

echo "***Deleting Folders to skip"
rm -rf ./cartridges/useless_folder

echo "***Installing NPM & Build project"
npm install --silent
npm run build --silent

echo "***Cleaning up manually build folder"
#Since workspace is always cleaned, this step is optional
rm -rf ./$BUILD_VERSION
mkdir ./$BUILD_VERSION

echo "***Preparing to package project - rsync"
#skipping files: .project *.java *.docx *.cpp *.php
#skipping folders: junk
rsync -rq --exclude={'.project','*.java','*.cpp','*.php'} --exclude={'junk'} ./cartridges/ $BUILD_VERSION

echo "***Packaging deployable artifact - 7z"
#"-mx[N]" specifies compression level
#"-mmt[N]" set number of CPU threads
7zz a $BUILD_VERSION.zip $BUILD_VERSION -mx9 -mmt16


Code deploy

Nothing new here, feel free to reuse the one we did on our first iteration.



Have fun!