Build and Deployment automation is possible in SAP Commerce Cloud now, want to know how?
SAP has recently released Commerce Cloud build APIs for SAP Commerce Cloud V2 (CCV2) to trigger and track builds. So far the build and deployment process has been manual in SAP Commerce Cloud through the Cloud portal. I developed a Proof of concept (POC) to implement build automation in CCV2 using the above APIs.
Through this POC, I have experimented initiating a code build automatically in CCV2 when some code is pushed/merged to the main branch thus delivering the continuous integration feature which is missing in CCV2. I further extended this by trying out continuous delivery and deployment.
I have leveraged Cloud Functions from Google Cloud Platform to implement this POC, Most likely the same kind of implementation can be done in any CI/CD tools which can call REST APIs.
How it is really done
The flow starts with the developer merging or pushing some code to the main branch in Bitbucket, which triggers a cloud function in Google Cloud Platform, that communicates with the SAP Commerce Cloud build platform through a series of API calls, that builds the code pushed to the main branch and deploys the build into the Commerce environment.
Let’s dive a little deeper
I have created a cloud function in Google cloud platform that uses an HTTP trigger. Then I have created a webhook in Bitbucket which triggers the cloud function when some code is pushed or merged into the main branch.
Within the cloud function, there is logic to call createBuild REST API which notifies SAP Commerce Cloud Build Platform to pull the latest code from the main branch and trigger a code build and returns the build ID to the cloud function. Using the build ID got from the API response, the cloud function then checks if the build is completed using getBuild REST API. Based on the build completion response from the API, the cloud function then triggers a code deployment of the newly created build in SAP Commerce Cloud Build Platform using the createDeployment REST API.
In SAP Commerce Cloud Portal, the build and deployment have been a manual process so far. This POC automates this process through Continuous integration, delivery and deployment using the newly released Commerce Cloud build APIs. There are few downsides needing to call multiple APIs one to create build, another to check if the build is completed and the last one to create a deployment with the build, but if there was a single API which does all of these operations it would have been much more intuitive.
The next steps are to integrate this POC with slack (the communication channel I mainly use) to provide notifications on the build and deployment progress as this is something that is not available out of the box in the current SAP Commerce Cloud.
Commerce Cloud API Documentation – SAP Help Portal
Documentation on how to authenticate to cloud API – API Tokens
Thank you so much for sharing this information as POC. It really helped me a lot. But still I would like to clarify some of the doubts since you implemented build and deployment automation in SAP commerce cloud such as:
I know I posted so many doubts but it would be nice to everyone if we get clarified it for better understanding
Did you get answers to the above questions that you posted ? I'm curious to know the solution to your ask...