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 is based on using the distribution moc-builder has been installed. Please configuration for helm. If you do not have the distribution moc-configuration, 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 forJENKINS_URI
, likehttps://jenkins.mycompany.com:8080/project
In
secrets/secrets.json
add values forJENKINS-USERNAME
andJENKINS-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
language | bash |
---|
For instructions on installing helm, see: https://helm.sh/docs/intro/install/
moc-configuration Jenkins Configuration
The configuration properties for Jenkins are located in application.yaml
. Edit the following properties:
Code Block | ||
---|---|---|
| ||
modelop:
jenkins-url:
jenkins-user:
jenkins-password: |
As an example, these properties might look as follows:
Code Block | ||
---|---|---|
| ||
modelop:
jenkins-url: https://foo.jenkins.com
jenkins-user: jenkins@modelop.com
jenkins-password: jenkinspass |
where https://foo.jenkins.com
is the Jenkins URL, jenkins@modelop.com
is the user name, and jenkinspass
is the password.
Next, ensure the configuration is active in the fleet.
If using sscs backed by git, commit the changes and refresh the actuator or restart mlc-manager
If using a configmap, run helm upgrade, restart sccs, and refresh the actuator or restart mlc-manager
Jenkins Job Monitor Configuration
The Jenkins Job monitor is a background task that periodically queries the state of Jenkins jobs and reacts appropriately to that state. The Jenkins job monitor comes with defaults but values can be configured to meet customer needs.
The default Jenkins Job Monitor Configuration is located in model-manage.yaml
and is defined as follows:
Code Block | ||
---|---|---|
| ||
jenkins-job-monitor: active-job-poll-rate: 2000 10000 |
The available configuration properties are discussed below.
active-job-poll-rate
- The amount of time in milliseconds between checking the status of tracked, active Jenkins jobs.
After setting these properties ensure the configuration is updated in the fleet as described above.
Additional Jenkins Credentials Configuration
The integration allows for multiple sets of Jenkins credentials if needed. The Jenkins credentials configuration is located in model-manage.yaml
and is defined as follows:
Code Block |
---|
jenkins-credentials: storedCredentials: - jenkinsUrl: ${JENKINS_URImodelop.jenkins-url} username: ${JENKINS_USERNAMEmodelop.jenkins-user} password: ${JENKINS_PASSWORD} |
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.json
and reference the new values in your environments/<environment>/spring_config/<type>/model-manager/application.yaml
and environments/<environment>/config/required.json
filesmodelop.jenkins-password} |
By default the jenkinsUrl
, username
, and password
are coming from the values set previously. The storedCredentials
section allows a list of these credentials to be specified. The correct credentials to use for a Jenkins job is based on matching criteria described below.
After setting these properties ensure the configuration is updated in the fleet as described above.
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