Installation Procedure for Adding a CD Jenkins Job(3.0)

The installation process for adding a CD Jenkins job includes the following steps:

  1. Add a new Item as type Freestyle project.

  2. Click This project is parameterized and add the following parameters:
    Parameter TypeName
    String parameter

    ClusterContext
    Namespace
    dockerRepo
    Release
    mzcliUser

    Password ParametermzcliPassword
    Build selector for Copy ArtifactBuildFromCIPipeline
    BooleanDEBUG
    install_crd



  3. Add Source Code Management, select Git and add your Repository URL, credentials, and branch.

    Note!

    You need to add Git repository only if you are using canary deploy.


    Canary deploy

    At the time of canary deploy, there is one canary and one production pod. In case of a new installation, both canary and production pods will run the same workflow. After that is deployed, the Git repository is updated with the information about which package_image the production pod will use. So the next time you deploy a new version, only the canary pod is updated and then you must verify the canary deploy first by running the canary deploy Jenkins job. When you feel that canary deploy is good, you can switch the canary pod with production pod and then the git repo needs to be updated with the new version of the production pod. 



  4. In the Build section:
    1. Add build step as Copy artifacts from another project.
      Add your CI pipeline as Project name.
      Under Which build, select Specified by a build parameter and set Parameter Name to BuildFromCIPipeline.
    2. Add build step Execute shell with this command:

      #!/bin/bash
      if [[ $DEBUG == "true" ]]; then
        set -x
      fi
      set -e
      cd output
      ls
      unzip *.csar
      echo Switch context to $ClusterContext
      kubectl config use-context $ClusterContext
      if [[ $mzcliUser != "" ]]; then
       MZCLI="-u $mzcliUser -p $mzcliPassword"
      fi
      #Usage ./install.sh -r <repo> -s <release> -g <Git Helmchart dir> -m <commit message> -n <namespace> -u <mzcli user> -p <mzcli password> -a <use specific AWS profile name and authenticate>
      ./install.sh -r $dockerRepo -n $Namespace -s $Release -g <Change to your Git Helmchart dir> -m <Change to your commit message> $MZCLI -a <Change to AWS Profile name if images is on AWS ECR> -i $install_crd
      tar -cvf Helm.tar Helm
      mv Helm.tar ../
      cd ..
      rm -rf output

      Install.sh script

      The install.sh script creates a Kubernetes Secret named mzcliwith two keys, one named mzcliUserand one named mzcliPasswordThe values are set to the values of the -u and -p parameters. When the -u parameter is not provided, a secret named mzclineeds to exist in the cluster in advance.

      Use -g and -m parameters if any of the Helm chart is using canary deploy.

      Use -a only if images is located on AWS ECR

  5. Add two Post-build Actions:
    1. Archive the artifacts with Files to archive set to Helm.tar.
    2. A Git Publisher. Select Push Only If Build Succeeds and add your Branch to push to.

      Note!

      You need to add Git repository only if you are using canary deploy.


  6. Apply your changes.

  7. When selecting Build with Parameters it should now look like this (the picture contains example field values):