Continuous Integration and Continuous Delivery of customizations

OpenShift® Container Platform provides the capability to use custom builder images and define a build process to build customized images in a Continuous Integration and Continuous Delivery (CI/CD) pipeline. Sterling Order Management System Software supports CI/CD by using BuildConfig. For more information, see What Is a BuildConfig?

Before you begin

About this task

You can set up a build process that automatically triggers on pushing the extension or code changes to a linked Git repository, and builds new customized images by using the build process.

Procedure

  1. Create a yaml file, for example, BuildConfig.yaml and configure all the parameters.
    apiVersion: build.openshift.io/v1
    kind: BuildConfig
    metadata:
      name: <name of the build configuration>
      namespace: <namespace for build>
    spec:
      serviceAccount: <service account to be used for build>
      nodeSelector: {}
      source:
        type: Git
        git:
          uri: "<git_repository_url>"
    
          # URL of the Git repository that contains the customization source code and corresponding build scripts.
        sourceSecret:
    
          name: <git_repository_clone_secret>
    
          # Refers to the secret for accessing the Git repository
    
        contextDir: <directory which contains build.sh>
    
        # Directoy path where build.sh file exists.
    
      strategy:
        type: Custom
        customStrategy:
          forcePull: true
          exposeDockerSocket: true
          from:
            kind: ImageStreamTag
            name: <name:tag of om-base image used for build>
            namespace: <namespace containing om-base image>
          env:
            # Ensure that OMS_RHOS_CUSTOM_BUILD is set to "true" so that the entrypoint.sh of 
            # om-base image considers this image as the base image for build.
           - name: OMS_RHOS_CUSTOM_BUILD
             value: "true"
      output:
        to:
          kind: ImageStreamTag
          name: <name:tag for output image name>
        pushSecret:
          name: <reference of secret associated to service account used for pushing image.>
      triggers: []
    status:
      lastVersion: 0
    
  2. Run the following command to create the BuildConfig in Red Hat OpenShift Container Platform cluster.
    oc create -f BuildConfig.yaml -n <namespace>
  3. Ensure that the build.sh file is present within the configured contextDir in the Git repository.
    The following sample code illustrates build.sh file:
    #!/bin/bash
    
    # add your customization script here.
    
    cd /opt/ssfs/runtime/container-scripts/imagebuild
    ./generateImages.sh --MODE=app --WAR_FILES=smcfs --EXPORT=false
    
    # Add authentication to access the Red Hat OpenShift Container Platform Docker registry. 
    # Tag and push the images to Red Hat OpenShift Container Platform Docker registry.
    
    (echo "{ \"auths\": " ; sudo cat $PUSH_DOCKERCFG_PATH/.dockercfg ; echo "}") > /tmp/.dockercfg
    buildah tag om-app:10.0 ${OUTPUT_REGISTRY}/${OUTPUT_IMAGE}
    buildah push --tls-verify=false --authfile=/tmp/.dockercfg ${OUTPUT_REGISTRY}/${OUTPUT_IMAGE}
    Additionally, the following environment variables are present in build.sh with BuildConfig that you created in step 3:
    • SOURCE_REPOSITORY - Git repo URL
    • SOURCE_SECRET_PATH - Git secret
    • OUTPUT_REGISTRY - Red Hat OpenShift Container Platform Docker registry URL
    • OUTPUT_IMAGE - output image name as mentioned in output section of BuildConfig
    • PUSH_DOCKERCFG_PATH - This variable is available only if the exposeDockerSocket flag is set to true. Configure this variable to push images to Red Hat OpenShift Container Platform registry by using buildah.