Jenkins Build Engine

Calling DeployHub from Jenkins for microservice tracking.

You can setup Jenkins to call a DeployHub step inside the Jenkins Pipeline. The step will execute continuous configuration management of the Components and Applications creating new versions as changes progress, and continuous deployments of independent objects like microservices.

Using the Groovy Library for Jenkins Integration

The Jenkins integration uses the a DeployHub Jenkins Groovy Library to peform the following steps :

  • Continuous Configuration Management: The process of automatically versioning Components, like microservices, with their consuming Applications.
  • Moves: Allows Jenkins to tell DeployHub to push a new update from one state to the next.
  • Deploy: Allows Jenkins to tell DeployHub when the deployment needs to be executed.
  • Approvals: Tracks an Approval, with audit, between Jenkins and DeployHub Pro (not supported in DeployHub Team).

Installation

Update your Jenkins Configure System - Global Pipeline Libraries to load the DeployHub Groovy Library from Git as follows:

Jenkins Setup

Resources

Example Pipeline

This example will create a new Component Version for the Application Version listed in the pipeline. Then it will update the Attributes of the Component Version with information from Jenkins.

@Library('deployhub') _


 def app="ChiliUptimeApp"
 def environment=""
 def cmd=""
 def url="http://192.168.3.116:8181"
 def user="admin"
 def pw="admin"
 def dh = new deployhub();

 node {
    stage('Clone sources') {
        git url: 'https://github.com/DeployHubProject/Uptime-Jenkins-Pipeline.git'
    }

    stage ('Build') {
      def url="https://console.deployhub.com"
      def user="DHUSER"
      def pw="DHPASSWORD"
      def comp="GLOBAL.CSC589.chili.Development.bowl"
      def application="GLOBAL.CSC589.chili.Development.ChiliUptimeApp"  
      def appver = "1"
      def version = "0.1.0-109"
      def imagename = "chili-bowl"
      def String[] envs = ["GLOBAL.CSC589.chili.Development.Dev"]
      def endpoint = "GLOBAL.CSC589.chili.k8s"

      echo "${url}";
      echo "${comp}";
      echo "${version}";

      // create component version
      compid = dh.newComponentVersion(url, user, pw, comp, "", version);
      echo "Creation Done " + compid.toString();

      // update attrs
      def attrs = [
      buildnumber: env.BUILD_ID,
      ComponentType: "Helm Chart",
      Category: "Deploy",
      AlwaysDeploy: "Y",
      DeploySequentially: "Y",
      'creds["helmrepo"]': "ec2user",
      Chart: "stable/heartbeat",
      ChartVersion: "1.0.0",
      ChartNamespace: "dev1",
      'image.tag': "1.0.0"
     ];

      echo "${attrs}";
      data = dh.updateComponentAttrs(url, user, pw, comp, "", version , attrs);
      echo "Update Done " + data.toString();

      data = dh.newApplication(url, user, pw,application,appver, envs);
      echo "New Application " + data.toString();
      appid = data[0];

      data = dh.addCompVer2AppVer(url, user, pw, appid, compid);

      attrs = [
      appvar: "1234"
     ];
      echo "${attrs}";
      data = dh.updateApplicationAttrs(url, user, pw, application, appver , attrs);
      echo "App Attr Update Done " + data.toString();

      attrs = [
      envvar: "XXYY"
     ];
      echo "${attrs}";
      data = dh.updateEnvironmentAttrs(url, user, pw, envs[0], attrs);
      echo "Env Attr Update Done " + data.toString();

      attrs = [
      epvar: "WWW"
     ];
      echo "${attrs}";
      data = dh.updateEndpointAttrs(url, user, pw, endpoint, attrs);
      echo "Endpoint Attr Update Done " + data.toString();
  }

For more information see:

Last modified June 30, 2020: tomcat, weblogic (b3ce556)