-
Notifications
You must be signed in to change notification settings - Fork 0
Jenkins Configuration
Jenkins is one of the most common continuous integration/delivery tools used in open source and commercial software development. OpenShift provides a means to easily deploy a Jenkins instance within OpenShift.
Our recommended approach for product teams working on the OpenShift DevOps platform is to run a Jenkins instance in their "tools" project. Generally, this project will have been provisioned at project inception, along with one or more of "dev", "test", and "prod".
In cases where an initial BuildConfiguration exists (e.g. starting point is an Instant App), at the time of our provisioning process, we may instantiate a Jenkins instance with a simple Jenkins job to promote an image into "dev", "test" and "prod" environments.
Alternatively, a standard Jenkins instance can also be provisioned (e.g. by a development team member) using the "Add to Project" button in the web console, or oc new-app...
. to use the OpenShift Pipeline feature, a slightly different process (with a few variants) is followed. The sections below describe the processes.
OpenShift has a special BuildConfiguration strategy - JenkinsPipeline - that integrates OpenShift deeply with Jenkins, providing triggering and tracking of pipeline execution from within the OpenShift web console.
Provided that a suitable Jenkins instance exists within a project, creating a JenkinsPipeline BuildConfig will cause a pipeline to be added to the OpenShift UI , as well adding a pipeline to Jenkins. The state of the pipeline will be synchronized between Jenkins and OpenShift. This is achieved through direct support in OpenShift and the "OpenShift Sync" plugin on the Jenkins side.
A JenkinsPipeline strategy includes a reference to a Jenkinsfile, either inline, or a pointer to a GitHub source. Our recommended practice is to use a Jenkinsfile stored in a GitHub repository alongside your application code. Changes to this file will automatically be picked up with every execution of the pipeline defined in OpenShift/Jenkins.
#Provisioning Jenkins
Af referenced above, in order for the pipeline feature to function, a suitable
There is a capability to dynamically provision a Jenkins instance within a project at the time a BuildConfig with a JenkinsPipeline strategy is created. This automatic Jenkins provisioning be triggered if no service with the exact name of jenkins-pipeline-svc
exists within the project. The instance that will be auto-provisioned will be derived based on a set of platform-wide defaults. This may or may not be suitable for a given project, as the Jenkins instance will have only a minimal set of plugins.
For cases where a project requires a Jenkins instance configured in a manner other than the default instance, or requires specific plugins, please refer to the section below on creating a custom Jenkins image.
Creating a custom Jenkins image can be useful where the default image does not contain plugins required for your project, or you'd like to pre-populate the instance with configuration values rather than configured manually post-instantiation.
There is a repo located here that can be used as a starting point for creating a custom image.
The specific steps to follow to instantiate a custom pipeline-compatible Jenkins instance and service within your project are as found below.
Note: The commands below would typically be executed against your '-tools' project.
- Create a BuildConfiguration for your custom Jenkins image using the command below:
oc process -f https://raw.githubusercontent.com/BCDevOps/pathfinder-jenkins/master/openshift/custom-jenkins-build.yaml | oc create -f -
- Create a DeploymentConfig to deploy the custom image created above.
oc process jenkins-pipeline -n openshift -v JENKINS_SERVICE_NAME=jenkins-pipeline-svc -v JNLP_SERVICE_NAME=jenkins-jnlp -v NAMESPACE=<your-tools-namepsace> -v JENKINS_IMAGE_STREAM_TAG=custom-jenkins:latest | oc create -f -