This documentation will help you to setup a jenkins environment for the CI.
An operator, like Jenkins, can interact with the cluster using a service account token.
Execute this command to create a service account for jenkins:
kubectl apply -f jenkins/k8s/sa-jenkins-ssr.yaml
Each service account token can be generated with a specific validity:
kubectl create token jenkins -n spartacus-ssr --duration=720h
The builder VMSS can be used as a Jenkins slave node to deploy the Spartacus project. Install the following tools:
ssh <VMSS_ADMIN_USERNAME>@<VMSS_PUBLIC_IP> 'bash -s' < jenkins/agent.sh
You can run jenkins locally to test the pipeline:
docker compose up
Connect to http://127.0.0.1:8080/ and proceed with a default installation.
The spartacus pipeline required the following plugin installed:
Create a new jenkins node (aka agent) as follow:
- Remote root directory: Any directory available in the builder VM (e.g. /home/builder/jenkins-agent)
- Labels: spartacus-builder
- Launch method: Launch Agent via SSH (use builder VMSS credentials)
The spartacus pipeline required the following credentials configured:
- [
Secret Text
] NPM_CREDENTIAL_SPARTACUS - NPM base64 token to access to "spartacus" repository - see SAP HELP to generate it. - [
Username/Password
] DOCKER_REPO_CREDENTIAL - Credential to access to docker repository (image repository). - [
Secret Text
] K8S_TOKEN - The service account token used to execute operation on the AKS cluster.
The project provides two simple pipelines as starting points for the CI/CD:
- build.Jenkinsfile - pipeline used to build the Spartacus project and push the image on the remote repository.
- deploy.Jenkinsfile - pipeline used to deploy the Spartacus helm chart to a remote cluster.
NOTE Import the two pipeline as multibranch pipeline
Update the build.Jenkinsfile to reflect the project's setting:
- SPARTACUS_APP_NAME: The name of the Spartacus application to build (defined in the package.json)
- SPARTACUS_REPO_URL: The ACR repository URL (e.g. https://<acr_name>.azurecr.io)
- SPARTACUS_IMAGE_NODE: The final name of the node image
- SPARTACUS_IMAGE_NGINX: The final name of the node image
Update the deploy.Jenkinsfile to reflect the project's setting:
- SPARTACUS_IMAGE_NODE: The name of the node image to deploy.
- SPARTACUS_IMAGE_NGINX: The name of the node image to deploy.
NOTE: The "clusterMap" is used to support multiple clusters to allow flexible deployments.