Loading, please wait...

A to Z Full Forms and Acronyms

Azure DevOps CI/CD pipeline for SAP Hybris and Commerce

Feb 02, 2021 AzureDevOps, 4029 Views
Azure DevOps CI/CD pipeline for SAP Hybris and Commerce

Azure DevOps CI/CD pipeline for SAP Hybris and Commerce

Continuous Integration

In this article i am going to talk about CI/CD process for deploying SAP Hybris and Spartacus to end systems.

One of the biggest challenge anyone faces with respect to deployment is lack of documentation as most them talks about pipelines using Jenkins. In order to setup there are some pre-requisites as you need to have latest zip files from SAP.

In this case, I am using below files.

  • CXCOMINTPK200500P_0–80005540.ZIP
  • CXCOMM201100P_0–70005693.ZIP
  • cloudhotfolder_2005.zip
  • Linux Server → Best is either Ubuntu 18.04 or RHEL 7

Make sure you add these 3 zip files onto your AzureDevOps code repo.

Now let's start creating CI Pipeline using AzureDevOps. I have checked in my code and with new zip files.

Now let's start creating a new Pipeline → click on New Pipeline → click on “use classic editor” → On the next screen it is going to ask the source of your code → to Select the appropriate Project, Repository & Branch.

Click on Continue → Select a template → empty job.

Now few Important things before you start adding the tasks, Under pipeline please select agent as “Ubuntu-18.04”. The reason behind selecting Ubuntu vs Windows as when I tried running the build using the Windows-2019 agent it was taking ~23mins to run however when I selected Ubuntu 18.04 agent entire job got completed in ~15mins (max).

Now let's add the tasks, as a part of the SAP Commerce Cloud build below are the steps that we need to add.

  1. Extract zip files
  2. Java 11 installation
  3. Install Hybris Commerce binaries.
  4. Prepare Hybris Commerce environment.
  5. standard Hybris Commerce full build.
  6. Install Yarn 1.15 or higher
  7. Initialize the Hybris Commerce system.
  8. Zip Spartacus Dist folder.
  9. Build to SAP Commerce Cloud.
  10. Initialize the JUnit Tests.
  11. Run Integration Tests.
  12. Run SonarQube Tests.
  13. Deploy to SAP Commerce Cloud.
  14. Copy Build artifacts as a zip file.
  15. Publish Artifacts.


  1. So let's start adding tasks onto our first AzureDevOps CI Pipeline. The first step is to extract zip files from the code repository so I am going to add the Extract task.

Add Destination folder as “Core customize”.Provide the archive file patterns which needs to be extracted, so in my case, i added both CX zip files

Make sure to uncheck “Clean Destination folder before extracting” and select “Overwrite existing files”.

2. Now we need to perform a similar extract operation on the “Cloudhotfolder” zip file.

3. Next is we need to add a task for Java installation, make sure it has to be minimum Java 11. So I have provided a zip file name that needs to be extracted, the reason for separating out this task from the previous one is because as it is going to generate the “Dist” folder which is specifically used by the Spartacus project. That's the reason i have selected the destination folder as “$(System.DefaultWorkingDirectory)/core-customize/hybris/bin/modules”

4. Next step is before you start the actual SAP Hybris build we need to Set the Ant environment. So I am going to use the Bash task to perform the same. In our case, I am going to use an Inline script as it is easy to run. select JDK version as 11, with X64 architecture and JDK source as “pre-installed”.

Another important thing to remember whenever you are running Bash script and calling Default working directory or Staging directory put a single quote before $ sign or it will throw an error. In this case, first, I am using “set-x” so that it enables a mode of the shell where all executed commands are printed to the terminal and easy for tracking (again it is an optional statement and good to have).

so I am using it as 

cd ‘$(System.DefaultWorkingDirectory)”/core-customize/hybris/bin/platform’

5. Next task is to run Ant customize command for SAP Hybris, so I am going to use a bash script to perform this.

cd ‘$(System.DefaultWorkingDirectory)’’/core-customize/hybris/bin/platform in this case I am setting my Directory to go to the below path as and then perform ANT operation.

6. Next we need to install YARN for SAP Commerce Cloud, as it's a pre-requisite to building application binaries.

Make sure to use ~1.15 version or higher.

7. Next step is to Add SAP Commerce(Spartacus) build task.

make sure to go “js-storefront/markethub” path to run “Yarn” command, so in my case i am using

cd ‘$(System.DefaultWorkingDirectory)’’/js-storefront/markethub’

after that add below commands

yarn run build:development 


make sure you select your working directory as “js-storefront”.

8. Next step is to run “ant production” command

Tasks 1–8 are mandatory in order to generate any SAP Hybris and SAP Commerce cloud artifacts.cd ‘$(System.DefaultWorkingDirectory)’’/core-customize/hybris/bin/platform’
ant production

from task 9–11 are a part of Continuous Automation/Testing.

9. Next task is to Integrate Junit testing as a part of Continuous Testing, so i have added Bash script task. In order to run JUnit tests first i am going to bin/platform folder path and then setting ant environment. later i am executing ant unit tests command.

10. Next task is to add and run Integration tests, please add Bash task.set -x
cd ‘$(System.DefaultWorkingDirectory)’’/core-customize/hybris/bin/platform’
. ./setantenv.sh
ant unittests -Dtestclasses.packages=com.org.mh*

11. Next task is to check Code Quality and Code coverage using SonarQube. So again i am using Bash task and Added below statements to execute the task.set -x
cd ‘$(System.DefaultWorkingDirectory)’’/core-customize/hybris/bin/platform’
. ./setantenv.sh
ant integrationtests -Dtestclasses.packages=com.org.mh.test.controllers.*
set -x
cd ‘$(System.DefaultWorkingDirectory)’’/core-customize/hybris/bin/platform’
. ./setantenv.sh
ant customize
ant sonarcheck -Dsonar.branch.name=prashanth_testbranch

make sure to set your working directory as “core-customize” so that SonarQube can pick your repo and give results.

finally i am using Copy files task to save outputs and then publishing it, so that we can pick it up for “Continuous Deployment” pipeline.

in task please provide your source folder and target folder (it can vary based on your environment).

12. Next task is to copy files for SAP Commerce Cloud (spartacus).this task will extract and then copy all zip files to Hybris folder.

Source folder: $(System.DefaultWorkingDirectory)/js-storefront/markethub/dist/

Target folder: $(Build.ArtifactStagingDirectory)/dist

the Only difference between SAP Hybris and SAP Commerce Cloud copy task is on SAP Hybris i am just copying .zip files and in SAP Commerce Cloud task i am copying everything from Dist folder.

13. Finally Publishing artifacts, and i am using Publish artifacts task.

Let’s check the final generated artifacts → i just clicked on successfully completed job → on the top you have an option of published artifacts.


Continuous Deployment
So you can see under Hybris it has 4 required zip files and Under Dist it has all required files and folders which are required for SAP Commerce (Spartacus).


for Continuous deployment there are few pre-requisites needs to be done.

  1. As i am pushing code from AzureDevOps to Linux servers which are hosted on Azure so i have installed AzureDevOps agent on Linux server.
  2. Either it can be done using Deployment group.




First task I have added with Bash script where am executing shell script which will unpack the files and deploy it accordingly. 

cp -R $(System.DefaultWorkingDirectory)/_Hybris-CI/drop/Hybris/hybrisServer-*.zip /usr/MarketHub/deployment_pkg
cd /usr/MarketHub/deployment_pkg/

starthybrisdeployment.sh files following commands, so i just added at as single shell script.

cat hybris_deployment.sh 

cd /usr/Hybris/core-customize/hybris/bin/platform

. ./setantenv.sh


./hybrisserver.sh stop

cd /usr/Hybris/core-customize

dt=$(date +”%m%d%Y%H%M”) → this task will take backup

tar -cvzf hybris_$dt.tar.gz hybris

cd /usr/Hybris/core-customize/hybris/

unzip -o /usr/Hybris/deployment_pkg/hybrisServer-Platform.zip

unzip -o /usr/Hybris/deployment_pkg/hybrisServer-AllExtensions.zip

unzip -o /usr/Hybris/deployment_pkg/hybrisServer-Config.zip

unzip -o /usr/Hybris/deployment_pkg/hybrisServer-Licence.zip

chmod -R 775 /usr/Hybris/

cd /usr/Hybris/core-customize/hybris/bin/platform

. ./setantenv.sh

ant clean all

ant server

ant deploy

nohup ./hybrisserver.sh start & → this task will create a new service


2. Second task i have added with another Bash script which will copy dist files/folders from 

startspartacusdeployment.sh file consists of following commands:cp -R $(System.DefaultWorkingDirectory)/_Hybris-CI/drop/dist /usr/MarketHub/deployment_pkg/
cd /usr/MarketHub/deployment_pkg/

val1=$(ps -aux | grep “yarn” | grep “development” | awk ‘{print $2}’)
val2=$(netstat -tunlp | grep 9002 | awk ‘{print $7}’ |awk -F ‘/’ ‘{print $1}’)
echo “Stopping the Spartacus”

kill -9 $val1 $val2

dt=$(date +”%m%d%Y%H%M”) → taking backup of existing files

cd /usr/Spartacus/js-storefront/markethub

tar -cvzf dist_$dt.tar.gz dist

cp -pr /usr/Spartacus/deployment_pkg/dist /usr/Spartacus/js-storefront/markethub/.

cd /usr/Spartacus/js-storefront/markethub

yarn -version

yarn install

nohup yarn start — configuration=development — ssl &


for final validation i will login to my Linux server and go to the path where i am copying all required files before i extract.

So in my case “/usr/Markethub/deployment_pkg”

now if run “ls-ltr” it will show all my latest files.


Now lets try to launch Hybris admin console from your browser

Also try to open Swagger and BackOffice links as well to make sure they are also opening.

Feel free to drop your comments.

A to Z Full Forms and Acronyms

Related Article