Integrate with Jenkins

ModelOp Center seamlessly integrates with existing CI/CD systems, such as Jenkins, to allow enterprises to leverage existing IT investments.

Table of Contents

 

Introduction

ModelOp Center provides the ability to integrate with Jenkins to initiate and manage CI/CD pipelines as part of an overall Model Life Cycle.

Jenkins Integration Setup

Prerequisites

This guide assumes moc-builder has been installed. Please request download instructions for moc-builder here. This guide also assumes a running Jenkins instance. To have moc-builder bring up a Jenkins instance with the rest of your fleet, include the --jenkins flag. That will bring up a pod named jenkins, with the Jenkins service running on port 8089. Nothing is required of moc-builder for Jenkins when composing if you plan on integrating with a Jenkins instance outside of kubenetes.

moc-builder Jenkins Configuration

The following configurations are required to integrate Jenkins into ModelOp Center.

  • In the config/config.json file for the environment, in the translator->backing_services section, include a value for JENKINS_URI, like https://jenkins.mycompany.com:8080/project

  • In secrets/secrets.jsonadd values for JENKINS-USERNAMEand JENKINS-PASSWORD

In environments/<environment>/config/required.json, under variables->model-manager you should see JENKINS_URI, and under variables->secrets you should see JENKINS_USERNAME and JENKINS_PASSWORD.

In the environments/<environment>/spring_config/<type>/model-manager/application.yaml file you should see some Jenkins-specific config as below

model-manage: ... jenkins-job-monitor: active-job-poll-rate: 2000 jenkins-credentials: storedCredentials: - jenkinsUrl: ${JENKINS_URI} username: ${JENKINS_USERNAME} password: ${JENKINS_PASSWORD}

You can have multiple Jenkins instances listed in storedCredentials. When connecting to Jenkins, ModelOp Center will look through the list and use the JENKINS_USERNAME and JENKINS_PASSWORD corresponding to the JENKINS_URI that matches from your MLC. To have multiple sets of Jenkins credentials, add more values to secrets/secrets.jsonand reference the new values in your environments/<environment>/spring_config/<type>/model-manager/application.yaml and environments/<environment>/config/required.jsonfiles.

Jenkins Job Customization

The integration provides parameters to customize the creation and lifecycle of the Jenkins Job. The Java Class for the Create Jenkins Job activity is com.modelop.mlc.delegate.modelop.jenkins.CreateJenkinsJob.

Required Parameters

JENKINS_JOB_NAME - The job name on the Jenkins server to execute

JENKINS_URL - The fully qualified URL of the Jenkins server. E.g., https://jenkins.mycompany.com:8080/project

Optional Parameters

JENKINS_USERNAME - Username to attempt to locate credentials for

BUILD_PARAMETERS - Build parameters to use for the Jenkins job. The format is a list of name-list value pairs in the following format: [param_name]:[value],[value],....;[param_name]:[value],..... Each name-list value pair is separated by a semicolon. The name and list values are separated by a colon. Each value in the list is separated by a comma.

ASSOCIATED_MODEL - A DeployableModel model that is associated with the Jenkins job.

Example MLC Integration with Jenkins

An example sub-process utilizing a Jenkins job is shown below.

Once created the Jenkins job will appear on the Jobs page.

The metadata about the job along with logs are available on the Job info page.

Job-Specific Jenkins Metadata

The following fields are added to the base job fields

buildNumber- the number of the Jenkins build

buildParameters - the parameters used to initiate the Jenkins build

jenkinsBuildInfo - more information about the Jenkins build

jenkinsPipelineInfo - information about the pipeline used in the Jenkins build

jenkinsRuntime - the jenkinsUrl and username associated with the build

jobName - the name of the Jenkins job

model - information about the deployable model used in the build

queueId - id of the queue used in the Jenkins job

 

Related Articles

 

Â